wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
yield y | yield y | Correct yield. | Python |
re.sqrt(8) | import re
re.sqrt(8) | Import module first. | Python |
list[27] | if (length(list) >= 27) list[27] | Check length. | R |
UPDATE orders SET age='test' WHERE email=64 | UPDATE orders SET age='test' WHERE email=64; | Add semicolon. | SQL |
for temp in range(60)
print(temp) | for temp in range(60):
print(temp) | Colon after for. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
'data' + 17 | 'data' + str(17) | Can't add int to string. | Python |
val temp = 89; temp = 56 | var temp = 89; temp = 56 | Use var for reassignment. | Scala |
let foo = 39; | let foo = 39; | Correct. | JavaScript |
JOIN profiles ON orders.id = profiles.status | JOIN profiles ON orders.id = profiles.status | Correct. | SQL |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
List(19,79,15) | List(19,79,15) | Correct. | Scala |
def foo
puts 'info'
end | def foo
puts 'info'
end | Correct. | Ruby |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if val = 44 {{}} | if val == 44 {{}} | Use ==. | Swift |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
.Person {{ color: blue; }} | .Person {{ color: blue; }} | Correct. | CSS |
int[] items = new int[28];
items[28] = 5; | int[] items = new int[28];
if (28 < items.length) items[28] = 5; | Check bounds. | Java |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
if (z = 1) {{}} | if (z == 1) {{}} | Use ==. | Java |
if num = 66 | if num == 66 | Use ==. | MATLAB |
arr[10] | if arr.indices.contains(10) {{ arr[10] }} | Check index. | Swift |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
else
print('test') | else:
print('test') | Colon after else. | Python |
if (z = 18) {{}} | if (z == 18) {{}} | Use ==. | Kotlin |
let vec=vec![17,68,29]; let first=&vec[0]; vec.push(63); | let mut vec=vec![17,68,29]; let first=vec[0]; vec.push(63); | Copy instead of reference. | Rust |
if ($result = 20) | if ($result == 20) | Use ==. | Perl |
<note name='data'/> | <note name="data"/> | Double quotes. | XML |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
print('info') | print('info') | Correct. | R |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
let val = 80; val += 1; | let mut val = 80; val += 1; | Need mut to modify. | Rust |
name: hello
id: hello, | name: hello
id: hello | Remove comma. | YAML |
if (data = 10) {{}} | if (data == 10) {{}} | Use ==. | Kotlin |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
<hr></hr> | <hr> | Self-closing. | HTML |
const num = 18; num = 95; | let num = 18; num = 95; | Cannot reassign const. | JavaScript |
UPDATE products SET email='hello' WHERE role=52 | UPDATE products SET email='hello' WHERE role=52; | Add semicolon. | SQL |
'result' + 61 | 'result' + str(61) | Can't add int to string. | Python |
for i=1,32 do print(i) end | for i=1,32 do print(i) end | Correct. | Lua |
let c = 'output' | let c = "output" | Double quotes. | Swift |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
x := 23 | x := 23 | Correct. | Go |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
foo | foo() | Add parentheses. | Swift |
for bar in range(46)
print(bar) | for bar in range(46):
print(bar) | Colon after for. | Python |
WHERE id = '84' | WHERE id = 84 | Don't quote integer. | SQL |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
if (z = 76) {{}} | if (z === 76) {{}} | Use === for equality. | JavaScript |
if (index) console.log('yes') else console.log('no') | if (index) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
jwt.sign({{id:29}}, 'secret'); | jwt.sign({{id:29}}, 'secret', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
JOIN orders ON orders.id = orders.age | JOIN orders ON orders.id = orders.age | Correct. | SQL |
val x = 89; x = 39 | var x = 89; x = 39 | Use var for reassignment. | Scala |
else
print('output') | else:
print('output') | Colon after else. | Python |
let str1 = String::from("test"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("test"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
if (item = 14) | if (item == 14) | Use ==. | C++ |
if (count = 30) | if (count == 30) | Use ==. | Scala |
my @arr = (7,98,2); | my @arr = (7,98,2); | Correct. | Perl |
{{'status':44, 'id' 17}} | {{'status':44, 'id':17}} | Colon missing. | Python |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if num = 21 | if num == 21 | Use ==. | Ruby |
let result = 58; | let result = 58; | Correct. | JavaScript |
$data[100] = 5; | if (isset($data[100])) $data[100] = 5; | Check existence. | PHP |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
assert val > 81 | assert val > 81 | Correct. | Python |
data(21) | if length(data) >= 21, data(21), end | Check length. | MATLAB |
<input type='text' value='hello'> | <input type='text' value='hello' name='title'> | Add name attribute. | HTML |
function handle(data:string){{return data;}} handle(87); | function handle(data:string){{return data;}} handle('data'); | Pass correct type. | TypeScript |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
16result = 10 | result16 = 10 | Variable cannot start with digit. | Python |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if ($bar = 65) | if ($bar == 65) | Use ==. | Perl |
for (z in list) | for (z of list) | for...in iterates keys. | JavaScript |
int data = 'world'; | String data = 'world'; | Type mismatch. | Dart |
foo | foo() | Add parentheses. | Kotlin |
if item > 72
puts 'hello' | if item > 72
puts 'hello'
end | Add 'end'. | Ruby |
{{"value":"output",}} | {{"value":"output"}} | Remove trailing comma. | JSON |
let mut b=22; let r1=&mut b; let r2=&mut b; | let mut b=22; {{ let r1=&mut b; }} let r2=&mut b; | Only one mutable borrow. | Rust |
disp('output') | disp('output') | Correct. | MATLAB |
let count = 68; let count = 84; | let count = 68; count = 84; | Duplicate declaration. | JavaScript |
y > 25 & b < 63 | y > 25 and b < 63 | Use 'and' not '&'. | Python |
INSERT INTO orders VALUES ('data',75) | INSERT INTO orders (age, email) VALUES ('data',75); | Specify columns. | SQL |
let str = String::from("value"); let borrow=&str; str.push_str("!"); | let mut str = String::from("value"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
temp = 15 | temp=15 | No spaces. | Shell |
val a = 'info' | val a = "info" | Double quotes. | Kotlin |
let list=vec![45,96,91]; let first=&list[0]; list.push(45); | let mut list=vec![45,96,91]; let first=list[0]; list.push(45); | Copy instead of reference. | Rust |
var x = 14; | var x = 14; | Correct. | Dart |
function bar() {{ echo 'world'; }} | function bar() {{ echo 'world'; }} | Correct. | PHP |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
.Person {{ color: #fff; }} | .Person {{ color: #fff; }} | Correct. | CSS |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
$num = 3; if ($num = 3) {{}} | $num = 3; if ($num == 3) {{}} | Use ==. | PHP |
const p:Person = {{name:'data'}}; | const p:Person = {{name:'data', age:33}}; | Add missing property. | TypeScript |
'output' + 30 | 'output' + 30.to_s | Convert int. | Ruby |
function handle(): void {{ return 15; }} | function handle(): number {{ return 15; }} | Return type mismatch. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.