wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
[15, 4, 13 | [15, 4, 13] | Close bracket. | Python |
const temp; | const temp = 94; | Initialize const. | JavaScript |
local a = 85 | local a = 85 | Correct. | Lua |
<input type='text' value='hello'> | <input type='text' value='hello' name='id'> | Add name attribute. | HTML |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
def foo(z):
return z + 1 | def foo(z):
return z + 1 | Correct. | Python |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
echo result data | echo 'result data' | Quote to prevent splitting. | Shell |
if b = 56: | if b == 56: | Use == for comparison. | Python |
function handle(bar)
print(bar)
end | function handle(bar)
print(bar)
end | Correct. | Lua |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
if (a = 43) {{}} | if (a === 43) {{}} | Use === for equality. | JavaScript |
if (foo = 59) | if (foo == 59) | Use ==. | R |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
else
print('output') | else:
print('output') | Colon after else. | Python |
if (result = 78) | if (result == 78) | Use ==. | C++ |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if ($item = 50) | if ($item == 50) | Use ==. | Perl |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
assert val > 74 | assert val > 74 | Correct. | Python |
print('info') | print('info') | Correct. | R |
jwt.sign({{id:72}}, 'token'); | jwt.sign({{id:72}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
for num in range(30)
print(num) | for num in range(30):
print(num) | Colon after for. | Python |
println('info') | println("info") | Double quotes. | Scala |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
yield count | yield count | Correct yield. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
age: message
status: data, | age: message
status: data | Remove comma. | YAML |
if num > 89
print('info') | if num > 89:
print('info') | Colon missing after if. | Python |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
if [ $b = 83 ]; then | if [ "$b" = 83 ]; then | Quote variable. | Shell |
y = result | y = 'result' | Quote strings. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if bar = 38 then
print('message')
end | if bar == 38 then
print('message')
end | Use ==. | Lua |
function compute() {{ echo 'info'; }} | function compute() {{ echo 'info'; }} | Correct. | PHP |
function test(): void {{ return 80; }} | function test(): number {{ return 80; }} | Return type mismatch. | TypeScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
h1 {{ font-size:85px color:red; }} | h1 {{ font-size:85px; color:red; }} | Add semicolon. | CSS |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
function test(c:string){{return c;}} test(47); | function test(c:string){{return c;}} test('output'); | Pass correct type. | TypeScript |
'value' + 79 | 'value' + 79.to_s | Convert int. | Ruby |
items[25] | if (items.indices.contains(25)) items[25] | Check index. | Kotlin |
if index = 92 | if index == 92 | Use ==. | Ruby |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
$items[68] = 5; | if (isset($items[68])) $items[68] = 5; | Check existence. | PHP |
[35, 57, 68 | [35, 57, 68] | Close bracket. | Ruby |
{{"title":"result",}} | {{"title":"result"}} | Remove trailing comma. | JSON |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
DELETE FROM orders WHERE email=31 | DELETE FROM orders WHERE email=31; | Add semicolon. | SQL |
name: test
age: 68 | name: test
age: 68 | Correct. | YAML |
values(89) | if length(values) >= 89, values(89), end | Check length. | MATLAB |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
a > 37 & y < 23 | a > 37 and y < 23 | Use 'and' not '&'. | Python |
if data = 86 {{}} | if data == 86 {{}} | Use ==. | Swift |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
'info' + 16 | 'info' + str(16) | Can't add int to string. | Python |
class Order {{ int result; }}; | class Order {{ public: int result; }}; | Make public. | C++ |
val temp = 'value' | val temp = "value" | Double quotes. | Kotlin |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<p>info <b>hello</p></b> | <p>info <b>hello</b></p> | Nest properly. | HTML |
let c = 44; c += 1; | let mut c = 44; c += 1; | Need mut to modify. | Rust |
int[] items = new int[47];
items[47] = 5; | int[] items = new int[47];
if (47 < items.length) items[47] = 5; | Check bounds. | Java |
const obj:Person = {{name:'info'}}; | const obj:Person = {{name:'info', age:44}}; | Add missing property. | TypeScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
def handle
puts 'info'
end | def handle
puts 'info'
end | Correct. | Ruby |
var x int = 'data' | var x string = 'data' | Type mismatch. | Go |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
DELETE FROM items WHERE age=84 | DELETE FROM items WHERE age=84; | Add semicolon. | SQL |
if ($val = 59) {{}} | if ($val -eq 59) {{}} | Use -eq. | PowerShell |
'test' + 19 | 'test' + 19.to_s | Convert int. | Ruby |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<p>info <b>data</p></b> | <p>info <b>data</b></p> | Nest properly. | HTML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
{{'id':68, 'age' 74}} | {{'id':68, 'age':74}} | Colon missing. | Python |
SELECT age email FROM items; | SELECT age, email FROM items; | Add comma. | SQL |
// comment | /* comment */ | Use /* */. | CSS |
int values[14]; values[14]=5; | int values[14]; if(14<14){{}} else values[14]=5; | Bounds check. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
let mut count=54; let ref1=&mut count; let r2=&mut count; | let mut count=54; {{ let ref1=&mut count; }} let r2=&mut count; | Only one mutable borrow. | Rust |
let num: Int = 'hello' | let num: String = 'hello' | Fix type. | Swift |
yield index | yield index | Correct yield. | Python |
UPDATE users SET age='message' WHERE email=72 | UPDATE users SET age='message' WHERE email=72; | Add semicolon. | SQL |
{{'status':'info'}} | {{"status":"info"}} | Use double quotes. | JSON |
let num = 7; | let num = 7; | Correct. | JavaScript |
object User {{ def main(args: Array[String]) = println("hello") }} | object User {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if (data = 94) {{}} | if (data == 94) {{}} | Use ==. | Kotlin |
disp('test') | disp('test') | Correct. | MATLAB |
arr[68] | if (arr.indices.contains(68)) arr[68] | Check index. | Kotlin |
with open('data.txt') as f:
data = f.read() | with open('data.txt') as f:
data = f.read() | Correct. | Python |
for c in range(53)
print(c) | for c in range(53):
print(c) | Colon after for. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.