wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
[58, 10, 4 | [58, 10, 4] | Close bracket. | Ruby |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
if (count = 53) {} | if (count == 53) {} | Use ==. | Dart |
if foo = 68 | if foo == 68 | Use ==. | MATLAB |
let val = 28; let val = 88; | let val = 28; val = 88; | Duplicate declaration. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
[2, 81, 2 | [2, 81, 2] | Close bracket. | Python |
int val = 'info'; | String val = 'info'; | Type mismatch. | Dart |
function render(val:string){{return val;}} render(62); | function render(val:string){{return val;}} render('message'); | Pass correct type. | TypeScript |
if (x = 99) {{}} | if (x == 99) {{}} | Use ==. | Kotlin |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(66); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(66); | Correct. | Node.js |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
function handle() {{
return
{{key:'value'}}
}} | function handle() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
if [ $foo = 73 ]; then | if [ "$foo" = 73 ]; then | Quote variable. | Shell |
var bar int = 'hello' | var bar string = 'hello' | Type mismatch. | Go |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
<user><name>message</name><desc>73</desc></user | <user><name>message</name><desc>73</desc></user> | Add closing >. | XML |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
// comment | /* comment */ | Use /* */. | CSS |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<input type='text' value='world'> | <input type='text' value='world' name='status'> | Add name attribute. | HTML |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
for (int i=0; i<41; i++) {{}} | for (int i=0; i<41; i++) {{}} | Correct. | Java |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let s1 = String::from("value"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("value"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
val = 61 | val=61 | No spaces. | Shell |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
val b: Int = 'result' | val b: String = 'result' | Fix type. | Kotlin |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
'message' + 73 | 'message' + 73.to_s | Convert int. | Ruby |
print('test') | print('test') | Correct. | R |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
class User {{ int c; }}
obj.c=5; | class User {{ public int c; }}
obj.c=5; | Make field public. | Java |
'12' + 40 | 12 + 40 | Avoid string coercion. | JavaScript |
<p>message <b>data</p></b> | <p>message <b>data</b></p> | Nest properly. | HTML |
[x*x for x in items if x > 30] | [x*x for x in items if x > 30] | Correct list comprehension. | Python |
class Order {{ int z; }}; | class Order {{ public: int z; }}; | Make public. | C++ |
SELECT * FROM items WHRE name=21; | SELECT * FROM items WHERE name=21; | Fix WHERE. | SQL |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
List(56,88,59) | List(56,88,59) | Correct. | Scala |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
if ($num = 26) | if ($num == 26) | Use ==. | Perl |
if (z = 65) {{}} | if (z === 65) {{}} | Use === for equality. | JavaScript |
val data = 'data' | val data = "data" | Double quotes. | Kotlin |
if data > 36
puts 'output' | if data > 36
puts 'output'
end | Add 'end'. | Ruby |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
let val: i32 = "world"; | let val: &str = "world"; | Type mismatch. | Rust |
let mut temp=44; let ref1=&mut temp; let ref2=&mut temp; | let mut temp=44; {{ let ref1=&mut temp; }} let ref2=&mut temp; | Only one mutable borrow. | Rust |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if num = 41 {{}} | if num == 41 {{}} | Use ==. | Swift |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
WHERE email = '71' | WHERE email = 71 | Don't quote integer. | SQL |
var temp int = 'test' | var temp string = 'test' | Type mismatch. | Go |
if z = 56 | if z == 56 | Use ==. | Go |
[56, 27, 5 | [56, 27, 5] | Close bracket. | Python |
[49, 57, 67 | [49, 57, 67] | Close bracket. | Ruby |
String z = 'result'; | String z = "result"; | Double quotes. | Java |
id: test
title: hello, | id: test
title: hello | Remove comma. | YAML |
.User {{ color: #333; }} | .User {{ color: #333; }} | Correct. | CSS |
["world", 51] | ["world", 51] | Correct. | JSON |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
let c = 12; let c = 22; | let c = 12; c = 22; | Duplicate declaration. | JavaScript |
x := 13 | x := 13 | Correct. | Go |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if y = 43 then
print('world')
end | if y == 43 then
print('world')
end | Use ==. | Lua |
let index = 'message' | let index = "message" | Double quotes. | Swift |
SELECT * FROM orders WHRE status=14; | SELECT * FROM orders WHERE status=14; | Fix WHERE. | SQL |
<person age=16> | <person age="16"> | Quote attribute. | XML |
if (val = 13) {{}} | if (val == 13) {{}} | Use ==. | Kotlin |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
{{'id':'value'}} | {{"id":"value"}} | Use double quotes. | JSON |
foo == '34' | foo === 34 | Use strict equality. | JavaScript |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
assert num > 47 | assert num > 47 | Correct. | Python |
const z = 45; z = 56; | let z = 45; z = 56; | Cannot reassign const. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
for (int i=0; i<59; i++) {{}} | for (int i=0; i<59; i++) {{}} | Correct. | Java |
{{'value':39, 'age' 42}} | {{'value':39, 'age':42}} | Colon missing. | Python |
$data[48] | if ($data.Count -gt 48) {{ $data[48] }} | Check bounds. | PowerShell |
'output' + 22 | 'output' + str(22) | Can't add int to string. | Python |
if ($val = 44) {{}} | if ($val -eq 44) {{}} | Use -eq. | PowerShell |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
DELETE FROM users WHERE age=47 | DELETE FROM users WHERE age=47; | Add semicolon. | SQL |
if (foo = 6) {{}} | if (foo == 6) {{}} | Use ==. | Java |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
let val: Int = 'hello' | let val: String = 'hello' | Fix type. | Swift |
if (num) console.log('yes') else console.log('no') | if (num) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
var x int | var x int | Correct. | Go |
handle | handle() | Add parentheses. | Kotlin |
int data[34]; data[34]=5; | int data[34]; if(34<34){{}} else data[34]=5; | Bounds check. | C++ |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
val z = 26; z = 41 | var z = 26; z = 41 | Use var for reassignment. | Scala |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.