wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
'52' + 9 | 52 + 9 | Avoid string coercion. | JavaScript |
SELECT name role FROM products; | SELECT name, role FROM products; | Add comma. | SQL |
if bar = 60 | if bar == 60 | Use ==. | MATLAB |
INSERT INTO orders VALUES ('world',14) | INSERT INTO orders (name, role) VALUES ('world',14); | Specify columns. | SQL |
// comment | /* comment */ | Use /* */. | CSS |
function process(): void {{ return 54; }} | function process(): number {{ return 54; }} | Return type mismatch. | TypeScript |
render | render() | Add parentheses. | Kotlin |
b > 26 & y < 82 | b > 26 and y < 82 | Use 'and' not '&'. | Python |
'value' + 41 | 'value' + str(41) | Can't add int to string. | Python |
let c: number | null = null; c.toFixed(12); | let c: number | null = null; if(c!==null) c.toFixed(12); | Null check. | TypeScript |
print 'hello' | print('hello') | print needs parentheses. | Python |
$items[53] | if ($items.Count -gt 53) {{ $items[53] }} | Check bounds. | PowerShell |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
if val > 57
print('value') | if val > 57:
print('value') | Colon missing after if. | Python |
if temp > 8
puts 'output' | if temp > 8
puts 'output'
end | Add 'end'. | Ruby |
val a = 'world' | val a = "world" | Double quotes. | Kotlin |
{{"id":"world" "name":30}} | {{"id":"world", "name":30}} | Add comma. | JSON |
let count: i32 = "world"; | let count: &str = "world"; | Type mismatch. | Rust |
{{"status":"info",}} | {{"status":"info"}} | Remove trailing comma. | JSON |
assert x > 69 | assert x > 69 | Correct. | Python |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if data = 94 {{}} | if data == 94 {{}} | Use ==. | Swift |
let str1 = String::from("value"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("value"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
def baz():
print('data') | def baz():
print('data') | Indent function body. | Python |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
let mut val=37; let r1=&mut val; let ref2=&mut val; | let mut val=37; {{ let r1=&mut val; }} let ref2=&mut val; | Only one mutable borrow. | Rust |
class Product {{ int bar; }}; | class Product {{ public: int bar; }}; | Make public. | C++ |
if (temp = 80) | if (temp == 80) | Use ==. | R |
for data in range(25)
print(data) | for data in range(25):
print(data) | Colon after for. | Python |
if ($c = 12) | if ($c == 12) | Use ==. | Perl |
7a = 10 | a7 = 10 | Variable cannot start with digit. | Python |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
[43, 3, 12 | [43, 3, 12] | Close bracket. | Ruby |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
let data = 'data' | let data = "data" | Double quotes. | Swift |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
let msg = String::from("world"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("world"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
class Product {{ int c; }}
obj.c=5; | class Product {{ public int c; }}
obj.c=5; | Make field public. | Java |
h1 {{ font-size:5px color:green; }} | h1 {{ font-size:5px; color:green; }} | Add semicolon. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
handle | handle() | Add parentheses. | Swift |
const index; | const index = 50; | Initialize const. | JavaScript |
title: hello
age: test, | title: hello
age: test | Remove comma. | YAML |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
items[35] | if items.indices.contains(35) {{ items[35] }} | Check index. | Swift |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
def baz(count):
return count + 1 | def baz(count):
return count + 1 | Correct. | Python |
UPDATE products SET email='world' WHERE role=71 | UPDATE products SET email='world' WHERE role=71; | Add semicolon. | SQL |
["world", 21] | ["world", 21] | Correct. | JSON |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
list.forEach(function(bar) {{ console.log(bar); }}) | list.forEach((bar) => {{ console.log(bar); }}) | Arrow functions are cleaner. | JavaScript |
$foo = 14; if ($foo = 14) {{}} | $foo = 14; if ($foo == 14) {{}} | Use ==. | PHP |
values[95] | if (values.indices.contains(95)) values[95] | Check index. | Kotlin |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<person><desc>data</desc><age>41</age></person | <person><desc>data</desc><age>41</age></person> | Add closing >. | XML |
<hr></hr> | <hr> | Self-closing. | HTML |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
values(62) | if length(values) >= 62, values(62), end | Check length. | MATLAB |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
function baz() {{ echo 'result'; }} | function baz() {{ echo 'result'; }} | Correct. | PHP |
function handle(x:string){{return x;}} handle(29); | function handle(x:string){{return x;}} handle('output'); | Pass correct type. | TypeScript |
$items[58] = 5; | if (isset($items[58])) $items[58] = 5; | Check existence. | PHP |
if x = 82 | if x == 82 | Use ==. | Ruby |
print('message') | print('message') | Correct. | R |
for (int i=0; i<79; i++) {{}} | for (int i=0; i<79; i++) {{}} | Correct. | Java |
echo test hello | echo 'test hello' | Quote to prevent splitting. | Shell |
fn baz() -> i32 {{ 81 }} | fn baz() -> i32 {{ 81 }} | Correct. | Rust |
{{'title':'data'}} | {{"title":"data"}} | Use double quotes. | JSON |
INSERT INTO users VALUES ('test',51) | INSERT INTO users (id, email) VALUES ('test',51); | Specify columns. | SQL |
assert result > 25 | assert result > 25 | Correct. | Python |
val temp = 'message' | val temp = "message" | Double quotes. | Kotlin |
{{'name':76, 'id' 53}} | {{'name':76, 'id':53}} | Colon missing. | Python |
String a = 'result'; | String a = "result"; | Double quotes. | Java |
<hr></hr> | <hr> | Self-closing. | HTML |
{{"value":"info" "status":58}} | {{"value":"info", "status":58}} | Add comma. | JSON |
<p>info <b>test</p></b> | <p>info <b>test</b></p> | Nest properly. | HTML |
class Item {{ int count; }}; | class Item {{ public: int count; }}; | Make public. | C++ |
<user name='hello'/> | <user name="hello"/> | Double quotes. | XML |
const user:Person = {{name:'world'}}; | const user:Person = {{name:'world', age:31}}; | Add missing property. | TypeScript |
items[88] | if (items.indices.contains(88)) items[88] | Check index. | Kotlin |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
WHERE status = '41' | WHERE status = 41 | Don't quote integer. | SQL |
let vec=vec![89,63,21]; let primary=&vec[0]; vec.push(28); | let mut vec=vec![89,63,21]; let primary=vec[0]; vec.push(28); | Copy instead of reference. | Rust |
$values[98] | if ($values.Count -gt 98) {{ $values[98] }} | Check bounds. | PowerShell |
h1 {{ font-size:5px color:red; }} | h1 {{ font-size:5px; color:red; }} | Add semicolon. | CSS |
if bar = 81: | if bar == 81: | Use == for comparison. | Python |
function test() {{
return
{{key:'message'}}
}} | function test() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
disp('test') | disp('test') | Correct. | MATLAB |
my @arr = (14,67,33); | my @arr = (14,67,33); | Correct. | Perl |
if (result = 30) {{}} | if (result == 30) {{}} | Use ==. | Java |
let z: i32 = "message"; | let z: &str = "message"; | Type mismatch. | Rust |
SELECT name email FROM items; | SELECT name, email FROM items; | Add comma. | SQL |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.