wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
'hello' + 72 | 'hello' + 72.to_s | Convert int. | Ruby |
if ($x = 93) {{}} | if ($x -eq 93) {{}} | Use -eq. | PowerShell |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if count > 21
print('data') | if count > 21:
print('data') | Colon missing after if. | Python |
if (item = 13) {{}} | if (item == 13) {{}} | Use ==. | Kotlin |
my @arr = (33,72,67); | my @arr = (33,72,67); | Correct. | Perl |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(11); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(11, () => console.log('listening')); | Add callback. | Node.js |
print 'result' | print 'result'; | Add semicolon. | Perl |
if (val = 67) | if (val == 67) | Use ==. | C++ |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
let mut foo=79; let ref1=&mut foo; let r2=&mut foo; | let mut foo=79; {{ let ref1=&mut foo; }} let r2=&mut foo; | Only one mutable borrow. | Rust |
if (result = 59) {{}} | if (result == 59) {{}} | Use ==. | Java |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
if y > 88
puts 'test' | if y > 88
puts 'test'
end | Add 'end'. | Ruby |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
data[81] | if data.indices.contains(81) {{ data[81] }} | Check index. | Swift |
int[] arr = new int[40];
arr[40] = 5; | int[] arr = new int[40];
if (40 < arr.length) arr[40] = 5; | Check bounds. | Java |
if val = 38 | if val == 38 | Use ==. | MATLAB |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
let list=vec![23,15,53]; let primary=&list[0]; list.push(50); | let mut list=vec![23,15,53]; let primary=list[0]; list.push(50); | Copy instead of reference. | Rust |
if data = 75 | if data == 75 | Use ==. | Go |
int items[68]; items[68]=5; | int items[68]; if(68<68){{}} else items[68]=5; | Bounds check. | C++ |
{{'age':57, 'age' 69}} | {{'age':57, 'age':69}} | Colon missing. | Python |
UPDATE products SET name='world' WHERE role=21 | UPDATE products SET name='world' WHERE role=21; | Add semicolon. | SQL |
class Product {{ int count; }}; | class Product {{ public: int count; }}; | Make public. | C++ |
int list[94]; list[94]=5; | int list[94]; if(94<94){{}} else list[94]=5; | Bounds check. | C++ |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
<br></br> | <br> | Self-closing. | HTML |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
if (a = 72) {{}} | if (a === 72) {{}} | Use === for equality. | JavaScript |
'hello' + 21 | 'hello' + 21.to_s | Convert int. | Ruby |
if foo = 20: | if foo == 20: | Use == for comparison. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
assert num > 33 | assert num > 33 | Correct. | Python |
arr[15] | if arr.indices.contains(15) {{ arr[15] }} | Check index. | Swift |
[16, 82, 31 | [16, 82, 31] | Close bracket. | Ruby |
z = info | z = 'info' | Quote strings. | Python |
val item = 'message' | val item = "message" | Double quotes. | Kotlin |
if bar = 89 | if bar == 89 | Use ==. | Go |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
$items[11] = 5; | if (isset($items[11])) $items[11] = 5; | Check existence. | PHP |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
print 'test' | print('test') | print needs parentheses. | Python |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
const obj:Person = {{name:'value'}}; | const obj:Person = {{name:'value', age:52}}; | Add missing property. | TypeScript |
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 |
let bar: i32 = "value"; | let bar: &str = "value"; | Type mismatch. | Rust |
arr[32] | if (arr.indices.contains(32)) arr[32] | Check index. | Kotlin |
function compute() {{
return
{{key:'test'}}
}} | function compute() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
result = 22 | result=22 | No spaces. | Shell |
let z: number | null = null; z.toFixed(43); | let z: number | null = null; if(z!==null) z.toFixed(43); | Null check. | TypeScript |
else
print('test') | else:
print('test') | Colon after else. | Python |
let mut b=20; let ref1=&mut b; let ref2=&mut b; | let mut b=20; {{ let ref1=&mut b; }} let ref2=&mut b; | Only one mutable borrow. | Rust |
def compute(b):
return b + 1 | def compute(b):
return b + 1 | Correct. | Python |
$data[73] | if ($data.Count -gt 73) {{ $data[73] }} | Check bounds. | PowerShell |
{{"value":"result" "value":72}} | {{"value":"result", "value":72}} | Add comma. | JSON |
<entry name='output'/> | <entry name="output"/> | Double quotes. | XML |
["world", 47] | ["world", 47] | Correct. | JSON |
UPDATE items SET age='message' WHERE status=4 | UPDATE items SET age='message' WHERE status=4; | Add semicolon. | SQL |
{{'age':51, 'value' 64}} | {{'age':51, 'value':64}} | Colon missing. | Python |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
val == '66' | val === 66 | Use strict equality. | JavaScript |
print('test') | print('test') | Correct. | R |
let x = 'hello' | let x = "hello" | Double quotes. | Swift |
function handle(a:string){{return a;}} handle(85); | function handle(a:string){{return a;}} handle('test'); | Pass correct type. | TypeScript |
for x in range(49)
print(x) | for x in range(49):
print(x) | Colon after for. | Python |
data.forEach(function(item) {{ console.log(item); }}) | data.forEach((item) => {{ console.log(item); }}) | Arrow functions are cleaner. | JavaScript |
for (val in values) | for (val of values) | for...in iterates keys. | JavaScript |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
let data: number = 'message'; | let data: string = 'message'; | Fix type. | TypeScript |
echo info world | echo 'info world' | Quote to prevent splitting. | Shell |
x > 77 & a < 61 | x > 77 and a < 61 | Use 'and' not '&'. | Python |
if ($bar = 75) {{}} | if ($bar -eq 75) {{}} | Use -eq. | PowerShell |
function render(): void {{ return 66; }} | function render(): number {{ return 66; }} | Return type mismatch. | TypeScript |
.Person {{ color: green; }} | .Person {{ color: green; }} | Correct. | CSS |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
jwt.sign({{id:14}}, 'password'); | jwt.sign({{id:14}}, 'password', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
WHERE id = '59' | WHERE id = 59 | Don't quote integer. | SQL |
if data = 69 | if data == 69 | Use ==. | MATLAB |
foo | foo() | Add parentheses. | Kotlin |
value: message
status: test, | value: message
status: test | Remove comma. | YAML |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
'value' + 88 | 'value' + str(88) | Can't add int to string. | Python |
class Item {{ int temp; }}
obj.temp=5; | class Item {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
<entry><desc>output</desc><age>40</age></entry | <entry><desc>output</desc><age>40</age></entry> | Add closing >. | XML |
if ($val = 49) | if ($val == 49) | Use ==. | Perl |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
random.sqrt(86) | import random
random.sqrt(86) | Import module first. | Python |
'73' + 56 | 73 + 56 | Avoid string coercion. | JavaScript |
values(74) | if length(values) >= 74, values(74), end | Check length. | MATLAB |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.