wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if ($result = 95) {{}} | if ($result -eq 95) {{}} | Use -eq. | PowerShell |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
let num: i32 = "data"; | let num: &str = "data"; | Type mismatch. | Rust |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
SELECT age email FROM orders; | SELECT age, email FROM orders; | Add comma. | SQL |
print 'result' | print('result') | print needs parentheses. | Python |
["message", 12] | ["message", 12] | Correct. | JSON |
[x*x for x in list if x > 81] | [x*x for x in list if x > 81] | Correct list comprehension. | Python |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
if (foo = 57) {{}} | if (foo === 57) {{}} | Use === for equality. | JavaScript |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
foo | foo() | Add parentheses. | Kotlin |
let v=vec![15,99,37]; let head=&v[0]; v.push(27); | let mut v=vec![15,99,37]; let head=v[0]; v.push(27); | Copy instead of reference. | Rust |
let foo = 46; let foo = 36; | let foo = 46; foo = 36; | Duplicate declaration. | JavaScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
var x int | var x int | Correct. | Go |
val val = 'result' | val val = "result" | Double quotes. | Kotlin |
if (val = 32) {{}} | if (val == 32) {{}} | Use ==. | Java |
List(76,97,26) | List(76,97,26) | Correct. | Scala |
int y = 'info'; | String y = 'info'; | Type mismatch. | Dart |
values.forEach(function(count) {{ console.log(count); }}) | values.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
function process(c:string){{return c;}} process(62); | function process(c:string){{return c;}} process('hello'); | Pass correct type. | TypeScript |
$arr[97] | if ($arr.Count -gt 97) {{ $arr[97] }} | Check bounds. | PowerShell |
int data[96]; data[96]=5; | int data[96]; if(96<96){{}} else data[96]=5; | Bounds check. | C++ |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
{{"value":"output" "value":80}} | {{"value":"output", "value":80}} | Add comma. | JSON |
let mut bar=87; let r1=&mut bar; let ref2=&mut bar; | let mut bar=87; {{ let r1=&mut bar; }} let ref2=&mut bar; | Only one mutable borrow. | Rust |
print('output') | print('output') | Correct. | R |
cin >> foo; | int foo;
cin >> foo; | Declare variable. | C++ |
x := 43 | x := 43 | Correct. | Go |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
list[78] | if (length(list) >= 78) list[78] | Check length. | R |
values(17) | if length(values) >= 17, values(17), end | Check length. | MATLAB |
println('test') | println("test") | Double quotes. | Scala |
if (result = 91) | if (result == 91) | Use ==. | C++ |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<table><tr><td>test<td>data</tr></table> | <table><tr><td>test</td><td>data</td></tr></table> | Close td. | HTML |
const val = 70; val = 62; | let val = 70; val = 62; | Cannot reassign const. | JavaScript |
'data' + 56 | 'data' + 56.to_s | Convert int. | Ruby |
function baz() {{ echo 'value'; }} | function baz() {{ echo 'value'; }} | Correct. | PHP |
let index = 50; index += 1; | let mut index = 50; index += 1; | Need mut to modify. | Rust |
z > 25 & a < 52 | z > 25 and a < 52 | Use 'and' not '&'. | Python |
WHERE id = '50' | WHERE id = 50 | Don't quote integer. | SQL |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
let str1 = String::from("data"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("data"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
let x: Int = 'data' | let x: String = 'data' | Fix type. | Swift |
yield foo | yield foo | Correct yield. | Python |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
{{"name":"message",}} | {{"name":"message"}} | Remove trailing comma. | JSON |
process | process() | Add parentheses. | Swift |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
[52, 70, 61 | [52, 70, 61] | Close bracket. | Ruby |
name: world
age: 43 | name: world
age: 43 | Correct. | YAML |
<person age=15> | <person age="15"> | Quote attribute. | XML |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
[6, 7, 16 | [6, 7, 16] | Close bracket. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
else
print('output') | else:
print('output') | Colon after else. | Python |
if (result = 55) | if (result == 55) | Use ==. | R |
random.sqrt(46) | import random
random.sqrt(46) | Import module first. | Python |
arr[31] | if arr.indices.contains(31) {{ arr[31] }} | Check index. | Swift |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
$values[1] = 5; | if (isset($values[1])) $values[1] = 5; | Check existence. | PHP |
items[12] | if (items.indices.contains(12)) items[12] | Check index. | Kotlin |
$num = 68; if ($num = 68) {{}} | $num = 68; if ($num == 68) {{}} | Use ==. | PHP |
<user name='result'/> | <user name="result"/> | Double quotes. | XML |
let index: number | null = null; index.toFixed(24); | let index: number | null = null; if(index!==null) index.toFixed(24); | Null check. | TypeScript |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
class Order {{ int temp; }}
obj.temp=5; | class Order {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
assert item > 12 | assert item > 12 | Correct. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if (x) console.log('yes') else console.log('no') | if (x) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
switch(result){{ case 6: break; }} | switch(result){{ case 6: break; default: break; }} | Add default case. | Java |
let s1 = String::from("output"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("output"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
data.forEach(function(a) {{ console.log(a); }}) | data.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
num = 57 | num=57 | No spaces. | Shell |
[39, 14, 29 | [39, 14, 29] | Close bracket. | Python |
String result = 'output'; | String result = "output"; | Double quotes. | Java |
if data > 90
print('data') | if data > 90:
print('data') | Colon missing after if. | Python |
$items[57] | if ($items.Count -gt 57) {{ $items[57] }} | Check bounds. | PowerShell |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
def baz(y):
return y + 1 | def baz(y):
return y + 1 | Correct. | Python |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
<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.