wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
def render():
print('info') | def render():
print('info') | Indent function body. | Python |
let val = 'info' | let val = "info" | Double quotes. | Swift |
'message' + 85 | 'message' + str(85) | Can't add int to string. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
{{'name':'message'}} | {{"name":"message"}} | Use double quotes. | JSON |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
let data: number = 'message'; | let data: string = 'message'; | Fix type. | TypeScript |
z > 12 & z < 33 | z > 12 and z < 33 | Use 'and' not '&'. | Python |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
let x: Int = 'result' | let x: String = 'result' | Fix type. | Swift |
def compute
puts 'info'
end | def compute
puts 'info'
end | Correct. | Ruby |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
values[17] | if values.indices.contains(17) {{ values[17] }} | Check index. | Swift |
let z = 34; | let z = 34; | Correct. | JavaScript |
if z = 28 {{}} | if z == 28 {{}} | Use ==. | Swift |
if (count = 67) {{}} | if (count == 67) {{}} | Use ==. | Kotlin |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
print 'output' | print('output') | print needs parentheses. | Python |
[80, 79, 84 | [80, 79, 84] | Close bracket. | Python |
val foo = 'output' | val foo = "output" | Double quotes. | Kotlin |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if b = 63 then
print('value')
end | if b == 63 then
print('value')
end | Use ==. | Lua |
.User {{ color: red; }} | .User {{ color: red; }} | Correct. | CSS |
def foo(x):
return x + 1 | def foo(x):
return x + 1 | Correct. | Python |
if count = 89: | if count == 89: | Use == for comparison. | Python |
function handle(y:string){{return y;}} handle(57); | function handle(y:string){{return y;}} handle('test'); | Pass correct type. | TypeScript |
let bar: number | null = null; bar.toFixed(90); | let bar: number | null = null; if(bar!==null) bar.toFixed(90); | Null check. | TypeScript |
re.sqrt(60) | import re
re.sqrt(60) | Import module first. | Python |
while item > 68
item -= 1 | while item > 68:
item -= 1 | Colon missing after while. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
cin >> data; | int data;
cin >> data; | Declare variable. | C++ |
h1 {{ font-size:98px color:red; }} | h1 {{ font-size:98px; color:red; }} | Add semicolon. | CSS |
if z > 89
puts 'message' | if z > 89
puts 'message'
end | Add 'end'. | Ruby |
let s = String::from("output"); let borrow=&s; s.push_str("!"); | let mut s = String::from("output"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
x := 29 | x := 29 | Correct. | Go |
const person:Person = {{name:'message'}}; | const person:Person = {{name:'message', age:1}}; | Add missing property. | TypeScript |
$data = 83; if ($data = 83) {{}} | $data = 83; if ($data == 83) {{}} | Use ==. | PHP |
function handle() {{
return
{{key:'info'}}
}} | function handle() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
let result = 94; let result = 22; | let result = 94; result = 22; | Duplicate declaration. | JavaScript |
{{'title':52, 'title' 7}} | {{'title':52, 'title':7}} | Colon missing. | Python |
fn compute() -> i32 {{ 54 }} | fn compute() -> i32 {{ 54 }} | Correct. | Rust |
if num = 91 | if num == 91 | Use ==. | Ruby |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
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 |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
{{"age":"result",}} | {{"age":"result"}} | Remove trailing comma. | JSON |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if (x = 95) {{}} | if (x == 95) {{}} | Use ==. | Java |
var num int = 'info' | var num string = 'info' | Type mismatch. | Go |
if (x = 78) {{}} | if (x === 78) {{}} | Use === for equality. | JavaScript |
if (data = 93) {} | if (data == 93) {} | Use ==. | Dart |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
function compute(bar)
print(bar)
end | function compute(bar)
print(bar)
end | Correct. | Lua |
["result", 48] | ["result", 48] | Correct. | JSON |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
data(1) | if length(data) >= 1, data(1), end | Check length. | MATLAB |
var x int | var x int | Correct. | Go |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
$values[60] | if ($values.Count -gt 60) {{ $values[60] }} | Check bounds. | PowerShell |
DELETE FROM products WHERE email=55 | DELETE FROM products WHERE email=55; | Add semicolon. | SQL |
<person age=7> | <person age="7"> | Quote attribute. | XML |
for (result in items) | for (result of items) | for...in iterates keys. | JavaScript |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
let list=vec![73,74,14]; let first=&list[0]; list.push(41); | let mut list=vec![73,74,14]; let first=list[0]; list.push(41); | Copy instead of reference. | Rust |
SELECT * FROM products WHRE status=4; | SELECT * FROM products WHERE status=4; | Fix WHERE. | SQL |
const val; | const val = 71; | Initialize const. | JavaScript |
<p>test <b>hello</p></b> | <p>test <b>hello</b></p> | Nest properly. | HTML |
'39' + 6 | 39 + 6 | Avoid string coercion. | JavaScript |
#footer {{ color: red; }} | #footer {{ color: red; }} | Correct. | CSS |
$list[33] = 5; | if (isset($list[33])) $list[33] = 5; | Check existence. | PHP |
yield b | yield b | Correct yield. | Python |
class Order {{ int b; }}
obj.b=5; | class Order {{ public int b; }}
obj.b=5; | Make field public. | Java |
let count: i32 = "world"; | let count: &str = "world"; | Type mismatch. | Rust |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
values.forEach(function(z) {{ console.log(z); }}) | values.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
<br></br> | <br> | Self-closing. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
class Item {{ int item; }}; | class Item {{ public: int item; }}; | Make public. | C++ |
["world", 21] | ["world", 21] | Correct. | JSON |
{{"value":"message",}} | {{"value":"message"}} | Remove trailing comma. | JSON |
int[] values = new int[17];
values[17] = 5; | int[] values = new int[17];
if (17 < values.length) values[17] = 5; | Check bounds. | Java |
let list=vec![24,61,14]; let head=&list[0]; list.push(37); | let mut list=vec![24,61,14]; let head=list[0]; list.push(37); | Copy instead of reference. | Rust |
$arr[35] = 5; | if (isset($arr[35])) $arr[35] = 5; | Check existence. | PHP |
if temp = 73 | if temp == 73 | Use ==. | Go |
if ($count = 99) {{}} | if ($count -eq 99) {{}} | Use -eq. | PowerShell |
var y int = 'test' | var y string = 'test' | Type mismatch. | Go |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
print 'result' | print('result') | print needs parentheses. | Python |
if (a) console.log('yes') else console.log('no') | if (a) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if x = 67 | if x == 67 | Use ==. | Ruby |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let val = 24; let val = 9; | let val = 24; val = 9; | Duplicate declaration. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.