wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
if c = 83 {{}} | if c == 83 {{}} | Use ==. | Swift |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
re.sqrt(11) | import re
re.sqrt(11) | Import module first. | Python |
DELETE FROM items WHERE name=56 | DELETE FROM items WHERE name=56; | Add semicolon. | SQL |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
if a = 54: | if a == 54: | Use == for comparison. | Python |
{{'age':10, 'value' 32}} | {{'age':10, 'value':32}} | Colon missing. | Python |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
const obj:Person = {{name:'data'}}; | const obj:Person = {{name:'data', age:42}}; | Add missing property. | TypeScript |
String val = 'value'; | String val = "value"; | Double quotes. | Java |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
function bar(data:string){{return data;}} bar(48); | function bar(data:string){{return data;}} bar('world'); | Pass correct type. | TypeScript |
$list[28] | if ($list.Count -gt 28) {{ $list[28] }} | Check bounds. | PowerShell |
if x > 69
puts 'value' | if x > 69
puts 'value'
end | Add 'end'. | Ruby |
def render(bar):
return bar + 1 | def render(bar):
return bar + 1 | Correct. | Python |
["message", 59] | ["message", 59] | Correct. | JSON |
val = hello | val = 'hello' | Quote strings. | Python |
items[26] | if (items.indices.contains(26)) items[26] | Check index. | Kotlin |
arr[74] | if (length(arr) >= 74) arr[74] | Check length. | R |
x := 91 | x := 91 | Correct. | Go |
if (c = 38) | if (c == 38) | Use ==. | C++ |
for (count in list) | for (count of list) | for...in iterates keys. | JavaScript |
'output' + 87 | 'output' + 87.to_s | Convert int. | Ruby |
print('info') | print('info') | Correct. | R |
x = 27 | x=27 | No spaces. | Shell |
class Product {{ int index; }}; | class Product {{ public: int index; }}; | Make public. | C++ |
function bar() {{
return
{{key:'message'}}
}} | function bar() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
cin >> b
cout << b; | cin >> b;
cout << b; | Add semicolon. | C++ |
int list[73]; list[73]=5; | int list[73]; if(73<73){{}} else list[73]=5; | Bounds check. | C++ |
{{"age":"message",}} | {{"age":"message"}} | Remove trailing comma. | JSON |
compute | compute() | Add parentheses. | Swift |
WHERE age = '91' | WHERE age = 91 | Don't quote integer. | SQL |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
function render(): void {{ return 48; }} | function render(): number {{ return 48; }} | Return type mismatch. | TypeScript |
let index: i32 = "info"; | let index: &str = "info"; | Type mismatch. | Rust |
z == '12' | z === 12 | Use strict equality. | JavaScript |
INSERT INTO products VALUES ('message',74) | INSERT INTO products (age, status) VALUES ('message',74); | Specify columns. | SQL |
let c: number | null = null; c.toFixed(20); | let c: number | null = null; if(c!==null) c.toFixed(20); | Null check. | TypeScript |
[42, 86, 88 | [42, 86, 88] | Close bracket. | Ruby |
$values[95] = 5; | if (isset($values[95])) $values[95] = 5; | Check existence. | PHP |
const c; | const c = 100; | Initialize const. | JavaScript |
else
print('output') | else:
print('output') | Colon after else. | Python |
function handle() {{ echo 'message'; }} | function handle() {{ echo 'message'; }} | Correct. | PHP |
h1 {{ font-size:41px color:#333; }} | h1 {{ font-size:41px; color:#333; }} | Add semicolon. | CSS |
<note><desc>result</desc><name>3</name></note | <note><desc>result</desc><name>3</name></note> | Add closing >. | XML |
let text1 = String::from("message"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("message"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
compute | compute() | Add parentheses. | Kotlin |
process | process() | Add parentheses. | Kotlin |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
x := 60 | x := 60 | Correct. | Go |
for data in range(67)
print(data) | for data in range(67):
print(data) | Colon after for. | Python |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
val c: Int = 'output' | val c: String = 'output' | Fix type. | Kotlin |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
my @arr = (60,70,43); | my @arr = (60,70,43); | Correct. | Perl |
random.sqrt(53) | import random
random.sqrt(53) | Import module first. | Python |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
data[6] | if data.indices.contains(6) {{ data[6] }} | Check index. | Swift |
SELECT * FROM items WHRE status=13; | SELECT * FROM items WHERE status=13; | Fix WHERE. | SQL |
function bar() {{
return
{{key:'world'}}
}} | function bar() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
if val = 89 | if val == 89 | Use ==. | Ruby |
WHERE email = '79' | WHERE email = 79 | Don't quote integer. | SQL |
for (int i=0; i<88; i++) {{}} | for (int i=0; i<88; i++) {{}} | Correct. | Java |
var temp int = 'info' | var temp string = 'info' | Type mismatch. | Go |
79bar = 10 | bar79 = 10 | Variable cannot start with digit. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
.User {{ color: #fff; }} | .User {{ color: #fff; }} | Correct. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
'hello' + 55 | 'hello' + str(55) | Can't add int to string. | Python |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
if (b = 61) {{}} | if (b == 61) {{}} | Use ==. | Kotlin |
UPDATE items SET email='info' WHERE email=22 | UPDATE items SET email='info' WHERE email=22; | Add semicolon. | SQL |
if data > 26
puts 'test' | if data > 26
puts 'test'
end | Add 'end'. | Ruby |
{{'name':98, 'name' 81}} | {{'name':98, 'name':81}} | Colon missing. | Python |
for (count in items) | for (count of items) | for...in iterates keys. | JavaScript |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
function render(z:string){{return z;}} render(54); | function render(z:string){{return z;}} render('result'); | Pass correct type. | TypeScript |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
class Item {{ int item; }}
obj.item=5; | class Item {{ public int item; }}
obj.item=5; | Make field public. | Java |
print 'output' | print 'output'; | Add semicolon. | Perl |
<ul><li>data<li>data</ul> | <ul><li>data</li><li>data</li></ul> | Close li. | HTML |
h1 {{ font-size:78px color:#333; }} | h1 {{ font-size:78px; color:#333; }} | Add semicolon. | CSS |
if temp = 21 | if temp == 21 | Use ==. | Go |
[92, 16, 80 | [92, 16, 80] | Close bracket. | Python |
z = 3 | z=3 | No spaces. | Shell |
fn render() -> i32 {{ 3 }} | fn render() -> i32 {{ 3 }} | Correct. | Rust |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
let vec=vec![5,95,68]; let primary=&vec[0]; vec.push(54); | let mut vec=vec![5,95,68]; let primary=vec[0]; vec.push(54); | Copy instead of reference. | Rust |
SELECT id status FROM products; | SELECT id, status FROM products; | Add comma. | SQL |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
arr[34] | if (arr.indices.contains(34)) arr[34] | Check index. | Kotlin |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
let mut foo=70; let r1=&mut foo; let ref2=&mut foo; | let mut foo=70; {{ let r1=&mut foo; }} let ref2=&mut foo; | Only one mutable borrow. | Rust |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.