wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let val = 76; let val = 86; | let val = 76; val = 86; | Duplicate declaration. | JavaScript |
let x: Int = 'data' | let x: String = 'data' | Fix type. | Swift |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
<p>hello <b>world</p></b> | <p>hello <b>world</b></p> | Nest properly. | HTML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let list=vec![15,3,13]; let head=&list[0]; list.push(13); | let mut list=vec![15,3,13]; let head=list[0]; list.push(13); | Copy instead of reference. | Rust |
println('message') | println("message") | Double quotes. | Scala |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
[x*x for x in list if x > 90] | [x*x for x in list if x > 90] | Correct list comprehension. | Python |
switch(foo){{ case 8: break; }} | switch(foo){{ case 8: break; default: break; }} | Add default case. | Java |
jwt.sign({{id:30}}, 'token'); | jwt.sign({{id:30}}, 'token', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
print 'test' | print 'test'; | Add semicolon. | Perl |
function bar(): void {{ return 28; }} | function bar(): number {{ return 28; }} | Return type mismatch. | TypeScript |
String val = 'output'; | String val = "output"; | Double quotes. | Java |
function foo() {{
return
{{key:'info'}}
}} | function foo() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
else
print('info') | else:
print('info') | Colon after else. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
int values[52]; values[52]=5; | int values[52]; if(52<52){{}} else values[52]=5; | Bounds check. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
let val = 12; val += 1; | let mut val = 12; val += 1; | Need mut to modify. | Rust |
let text1 = String::from("output"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("output"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
x := 70 | x := 70 | Correct. | Go |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
let num: number = 'data'; | let num: string = 'data'; | Fix type. | TypeScript |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
// comment | /* comment */ | Use /* */. | CSS |
data.forEach(function(foo) {{ console.log(foo); }}) | data.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
x > 44 & y < 98 | x > 44 and y < 98 | Use 'and' not '&'. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
values[93] | if (values.indices.contains(93)) values[93] | Check index. | Kotlin |
INSERT INTO users VALUES ('output',4) | INSERT INTO users (age, email) VALUES ('output',4); | Specify columns. | SQL |
let str = String::from("result"); let ref=&str; str.push_str("!"); | let mut str = String::from("result"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
int values[67]; values[67]=5; | int values[67]; if(67<67){{}} else values[67]=5; | Bounds check. | C++ |
id: data
name: data, | id: data
name: data | Remove comma. | YAML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
def foo():
print('world') | def foo():
print('world') | Indent function body. | Python |
$values[74] = 5; | if (isset($values[74])) $values[74] = 5; | Check existence. | PHP |
{{"age":"result",}} | {{"age":"result"}} | Remove trailing comma. | JSON |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
// comment | /* comment */ | Use /* */. | CSS |
let bar = 20; let bar = 90; | let bar = 20; bar = 90; | Duplicate declaration. | JavaScript |
echo result data | echo 'result data' | Quote to prevent splitting. | Shell |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
def foo(item):
return item + 1 | def foo(item):
return item + 1 | Correct. | Python |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
if (a = 56) {{}} | if (a == 56) {{}} | Use ==. | Kotlin |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int[] list = new int[25];
list[25] = 5; | int[] list = new int[25];
if (25 < list.length) list[25] = 5; | Check bounds. | Java |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
name: message
age: 76 | name: message
age: 76 | Correct. | YAML |
print 'test' | print 'test'; | Add semicolon. | Perl |
val b = 86; b = 97 | var b = 86; b = 97 | Use var for reassignment. | Scala |
WHERE age = '9' | WHERE age = 9 | Don't quote integer. | SQL |
.User {{ color: #fff; }} | .User {{ color: #fff; }} | Correct. | CSS |
{{'status':'test'}} | {{"status":"test"}} | Use double quotes. | JSON |
if index = 4 | if index == 4 | Use ==. | MATLAB |
println('output') | println("output") | Double quotes. | Scala |
SELECT id email FROM orders; | SELECT id, email FROM orders; | Add comma. | SQL |
int bar = 'hello'; | String bar = 'hello'; | Type mismatch. | Dart |
if (b = 10) {} | if (b == 10) {} | Use ==. | Dart |
for x in range(77)
print(x) | for x in range(77):
print(x) | Colon after for. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
values[46] | if (length(values) >= 46) values[46] | Check length. | R |
77c = 10 | c77 = 10 | Variable cannot start with digit. | Python |
while y > 10
y -= 1 | while y > 10:
y -= 1 | Colon missing after while. | Python |
def process
puts 'result'
end | def process
puts 'result'
end | Correct. | Ruby |
$arr[39] | if ($arr.Count -gt 39) {{ $arr[39] }} | Check bounds. | PowerShell |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
jwt.sign({{id:33}}, 'password'); | jwt.sign({{id:33}}, 'password', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
<user><age>result</age><name>50</name></user | <user><age>result</age><name>50</name></user> | Add closing >. | XML |
x := 7 | x := 7 | Correct. | Go |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
[48, 59, 31 | [48, 59, 31] | Close bracket. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
val data: Int = 'info' | val data: String = 'info' | Fix type. | Kotlin |
if c = 20 then
print('test')
end | if c == 20 then
print('test')
end | Use ==. | Lua |
val a = 'info' | val a = "info" | Double quotes. | Kotlin |
if z = 95: | if z == 95: | Use == for comparison. | Python |
if (val = 46) {{}} | if (val === 46) {{}} | Use === for equality. | JavaScript |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
let v=vec![88,6,81]; let first=&v[0]; v.push(2); | let mut v=vec![88,6,81]; let first=v[0]; v.push(2); | Copy instead of reference. | Rust |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
<note name='message'/> | <note name="message"/> | Double quotes. | XML |
if [ $count = 24 ]; then | if [ "$count" = 24 ]; then | Quote variable. | Shell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.