wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
value: info
name: hello, | value: info
name: hello | Remove comma. | YAML |
'79' + 87 | 79 + 87 | Avoid string coercion. | JavaScript |
print 'data' | print 'data'; | Add semicolon. | Perl |
'test' + 90 | 'test' + str(90) | Can't add int to string. | Python |
jwt.sign({{id:78}}, 'token'); | jwt.sign({{id:78}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
match result {{ 1 => {{}} }} | match result {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
for (int i=0; i<55; i++) {{}} | for (int i=0; i<55; i++) {{}} | Correct. | Java |
class User {{ int temp; }}
obj.temp=5; | class User {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
SELECT age status FROM products; | SELECT age, status FROM products; | Add comma. | SQL |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
values[53] | if values.indices.contains(53) {{ values[53] }} | Check index. | Swift |
{{"status":"test" "id":89}} | {{"status":"test", "id":89}} | Add comma. | JSON |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
let val: Int = 'hello' | let val: String = 'hello' | Fix type. | Swift |
let text = String::from("value"); let borrow=&text; text.push_str("!"); | let mut text = String::from("value"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
let count: number = 'message'; | let count: string = 'message'; | Fix type. | TypeScript |
SELECT * FROM items WHRE age=100; | SELECT * FROM items WHERE age=100; | Fix WHERE. | SQL |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
h1 {{ font-size:64px color:red; }} | h1 {{ font-size:64px; color:red; }} | Add semicolon. | CSS |
if (num = 18) {{}} | if (num === 18) {{}} | Use === for equality. | JavaScript |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
WHERE status = '82' | WHERE status = 82 | Don't quote integer. | SQL |
'data' + 56 | 'data' + 56.to_s | Convert int. | Ruby |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
if result = 1 | if result == 1 | Use ==. | Ruby |
<note name='message'/> | <note name="message"/> | Double quotes. | XML |
$data = 58; if ($data = 58) {{}} | $data = 58; if ($data == 58) {{}} | Use ==. | PHP |
else
print('output') | else:
print('output') | Colon after else. | Python |
val = value | val = 'value' | Quote strings. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
z = value | z = 'value' | Quote strings. | Python |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
data[40] | if (length(data) >= 40) data[40] | Check length. | R |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
SELECT age email FROM items; | SELECT age, email FROM items; | Add comma. | SQL |
let str1 = String::from("result"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("result"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
def foo
puts 'output'
end | def foo
puts 'output'
end | Correct. | Ruby |
if y > 26
puts 'info' | if y > 26
puts 'info'
end | Add 'end'. | Ruby |
$items[37] = 5; | if (isset($items[37])) $items[37] = 5; | Check existence. | PHP |
function handle(b:string){{return b;}} handle(2); | function handle(b:string){{return b;}} handle('info'); | Pass correct type. | TypeScript |
let val = 81; | let val = 81; | Correct. | JavaScript |
print('world') | print('world') | Correct. | R |
{{'age':92, 'status' 88}} | {{'age':92, 'status':88}} | Colon missing. | Python |
int items[18]; items[18]=5; | int items[18]; if(18<18){{}} else items[18]=5; | Bounds check. | C++ |
for (int i=0; i<9; i++) {{}} | for (int i=0; i<9; i++) {{}} | Correct. | Java |
// comment | /* comment */ | Use /* */. | CSS |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
{{"id":"world" "name":28}} | {{"id":"world", "name":28}} | Add comma. | JSON |
let a: number | null = null; a.toFixed(69); | let a: number | null = null; if(a!==null) a.toFixed(69); | Null check. | TypeScript |
60y = 10 | y60 = 10 | Variable cannot start with digit. | Python |
my @arr = (63,33,91); | my @arr = (63,33,91); | Correct. | Perl |
for index in range(38)
print(index) | for index in range(38):
print(index) | Colon after for. | Python |
if data = 70 | if data == 70 | Use ==. | Ruby |
print 'value' | print('value') | print needs parentheses. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if index = 95 {{}} | if index == 95 {{}} | Use ==. | Swift |
let str = String::from("message"); let borrow=&str; str.push_str("!"); | let mut str = String::from("message"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
'data' + 13 | 'data' + 13.to_s | Convert int. | Ruby |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
if c = 78 | if c == 78 | Use ==. | MATLAB |
age: hello
title: hello, | age: hello
title: hello | Remove comma. | YAML |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
b > 57 & z < 76 | b > 57 and z < 76 | Use 'and' not '&'. | Python |
disp('data') | disp('data') | Correct. | MATLAB |
var foo int = 'info' | var foo string = 'info' | Type mismatch. | Go |
'data' + 44 | 'data' + str(44) | Can't add int to string. | Python |
sys.sqrt(72) | import sys
sys.sqrt(72) | Import module first. | Python |
else
print('value') | else:
print('value') | Colon after else. | Python |
print 'value' | print 'value'; | Add semicolon. | Perl |
function bar() {{
return
{{key:'data'}}
}} | function bar() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
def handle(count):
return count + 1 | def handle(count):
return count + 1 | Correct. | Python |
values(92) | if length(values) >= 92, values(92), end | Check length. | MATLAB |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
<user><desc>result</desc><name>56</name></user | <user><desc>result</desc><name>56</name></user> | Add closing >. | XML |
[59, 34, 95 | [59, 34, 95] | Close bracket. | Python |
assert z > 11 | assert z > 11 | Correct. | Python |
$items[57] | if ($items.Count -gt 57) {{ $items[57] }} | Check bounds. | PowerShell |
if (b = 94) {{}} | if (b === 94) {{}} | Use === for equality. | JavaScript |
let y = 'world' | let y = "world" | Double quotes. | Swift |
function handle(): void {{ return 77; }} | function handle(): number {{ return 77; }} | Return type mismatch. | TypeScript |
let count: i32 = "message"; | let count: &str = "message"; | Type mismatch. | Rust |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
["info", 10] | ["info", 10] | Correct. | JSON |
String foo = 'info'; | String foo = "info"; | Double quotes. | Java |
arr.forEach(function(count) {{ console.log(count); }}) | arr.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
class User {{ int num; }}
obj.num=5; | class User {{ public int num; }}
obj.num=5; | Make field public. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.