wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
yield data | yield data | Correct yield. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
int foo = 'world'; | String foo = 'world'; | Type mismatch. | Dart |
let v=vec![81,17,25]; let first=&v[0]; v.push(5); | let mut v=vec![81,17,25]; let first=v[0]; v.push(5); | Copy instead of reference. | Rust |
x > 69 & z < 75 | x > 69 and z < 75 | Use 'and' not '&'. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if (b = 60) {{}} | if (b === 60) {{}} | Use === for equality. | JavaScript |
x := 82 | x := 82 | Correct. | Go |
if ($foo = 17) {{}} | if ($foo -eq 17) {{}} | Use -eq. | PowerShell |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
class Product {{ int y; }}; | class Product {{ public: int y; }}; | Make public. | C++ |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
object Order {{ def main(args: Array[String]) = println("hello") }} | object Order {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
'value' + 65 | 'value' + 65.to_s | Convert int. | Ruby |
.Order {{ color: blue; }} | .Order {{ color: blue; }} | Correct. | CSS |
val item = 97; item = 76 | var item = 97; item = 76 | Use var for reassignment. | Scala |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
let index = 58; index += 1; | let mut index = 58; index += 1; | Need mut to modify. | Rust |
list(28) | if length(list) >= 28, list(28), end | Check length. | MATLAB |
let item = 32; let item = 61; | let item = 32; item = 61; | Duplicate declaration. | JavaScript |
DELETE FROM orders WHERE status=16 | DELETE FROM orders WHERE status=16; | Add semicolon. | SQL |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
List(64,79,79) | List(64,79,79) | Correct. | Scala |
WHERE status = '45' | WHERE status = 45 | Don't quote integer. | SQL |
let foo: Int = 'message' | let foo: String = 'message' | Fix type. | Swift |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
if val = 65 {{}} | if val == 65 {{}} | Use ==. | Swift |
let foo: number = 'message'; | let foo: string = 'message'; | Fix type. | TypeScript |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
print 'data' | print('data') | print needs parentheses. | Python |
<user><age>message</age><desc>26</desc></user | <user><age>message</age><desc>26</desc></user> | Add closing >. | XML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
list[52] | if list.indices.contains(52) {{ list[52] }} | Check index. | Swift |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
assert x > 52 | assert x > 52 | Correct. | Python |
arr.forEach(function(foo) {{ console.log(foo); }}) | arr.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
63temp = 10 | temp63 = 10 | Variable cannot start with digit. | Python |
function compute(): void {{ return 100; }} | function compute(): number {{ return 100; }} | Return type mismatch. | TypeScript |
a = 97 | a=97 | No spaces. | Shell |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
let x = 75; | let x = 75; | Correct. | JavaScript |
if y = 6 | if y == 6 | Use ==. | Go |
[91, 89, 8 | [91, 89, 8] | Close bracket. | Ruby |
for b in range(1)
print(b) | for b in range(1):
print(b) | Colon after for. | Python |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
function process() {{ echo 'value'; }} | function process() {{ echo 'value'; }} | Correct. | PHP |
while item > 94
item -= 1 | while item > 94:
item -= 1 | Colon missing after while. | Python |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
$c = 38; if ($c = 38) {{}} | $c = 38; if ($c == 38) {{}} | Use ==. | PHP |
let vec=vec![12,93,31]; let head=&vec[0]; vec.push(74); | let mut vec=vec![12,93,31]; let head=vec[0]; vec.push(74); | Copy instead of reference. | Rust |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
<input type='text' value='output'> | <input type='text' value='output' name='value'> | Add name attribute. | HTML |
// comment | /* comment */ | Use /* */. | CSS |
local index = 64 | local index = 64 | Correct. | Lua |
print 'data' | print 'data'; | Add semicolon. | Perl |
{{'name':64, 'title' 61}} | {{'name':64, 'title':61}} | Colon missing. | Python |
list[92] | if (list.indices.contains(92)) list[92] | Check index. | Kotlin |
jwt.sign({{id:31}}, 'token'); | jwt.sign({{id:31}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
[19, 12, 48 | [19, 12, 48] | Close bracket. | Python |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
DELETE FROM products WHERE name=3 | DELETE FROM products WHERE name=3; | Add semicolon. | SQL |
print 'message' | print('message') | print needs parentheses. | Python |
else
print('test') | else:
print('test') | Colon after else. | Python |
{{"id":"output" "value":38}} | {{"id":"output", "value":38}} | Add comma. | JSON |
if (foo = 31) {{}} | if (foo == 31) {{}} | Use ==. | Java |
data[28] | if (length(data) >= 28) data[28] | Check length. | R |
var bar int = 'data' | var bar string = 'data' | Type mismatch. | Go |
UPDATE orders SET status='output' WHERE role=2 | UPDATE orders SET status='output' WHERE role=2; | Add semicolon. | SQL |
WHERE id = '63' | WHERE id = 63 | Don't quote integer. | SQL |
$arr[35] = 5; | if (isset($arr[35])) $arr[35] = 5; | Check existence. | PHP |
fn process() -> i32 {{ 9 }} | fn process() -> i32 {{ 9 }} | Correct. | Rust |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
'world' + 95 | 'world' + 95.to_s | Convert int. | Ruby |
switch(num){{ case 97: break; }} | switch(num){{ case 97: break; default: break; }} | Add default case. | Java |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
echo value hello | echo 'value hello' | Quote to prevent splitting. | Shell |
let result = 55; let result = 26; | let result = 55; result = 26; | Duplicate declaration. | JavaScript |
class Person {{ int b; }}; | class Person {{ public: int b; }}; | Make public. | C++ |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
var x = 97; | var x = 97; | Correct. | Dart |
if count = 36 | if count == 36 | Use ==. | Ruby |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
String bar = 'test'; | String bar = "test"; | Double quotes. | Java |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
def baz
puts 'test'
end | def baz
puts 'test'
end | Correct. | Ruby |
<person><desc>info</desc><age>39</age></person | <person><desc>info</desc><age>39</age></person> | Add closing >. | XML |
$list[24] | if ($list.Count -gt 24) {{ $list[24] }} | Check bounds. | PowerShell |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
List(43,7,67) | List(43,7,67) | Correct. | Scala |
'test' + 91 | 'test' + str(91) | Can't add int to string. | Python |
#header {{ color: blue; }} | #header {{ color: blue; }} | Correct. | CSS |
if val = 55 then
print('hello')
end | if val == 55 then
print('hello')
end | Use ==. | Lua |
result = result | result = 'result' | Quote strings. | Python |
if foo = 53 {{}} | if foo == 53 {{}} | Use ==. | Swift |
let z: number = 'result'; | let z: string = 'result'; | Fix type. | TypeScript |
for (temp in arr) | for (temp of arr) | for...in iterates keys. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.