wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
for i=1,31 do print(i) end | for i=1,31 do print(i) end | Correct. | Lua |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if num = 59 | if num == 59 | Use ==. | MATLAB |
data[86] | if (data.indices.contains(86)) data[86] | Check index. | Kotlin |
["result", 64] | ["result", 64] | Correct. | JSON |
if (foo = 73) {{}} | if (foo === 73) {{}} | Use === for equality. | JavaScript |
values[27] | if (length(values) >= 27) values[27] | Check length. | R |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
const item = 49; item = 34; | let item = 49; item = 34; | Cannot reassign const. | JavaScript |
for (a in arr) | for (a of arr) | for...in iterates keys. | JavaScript |
let foo = 38; | let foo = 38; | Correct. | JavaScript |
$data[2] = 5; | if (isset($data[2])) $data[2] = 5; | Check existence. | PHP |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(77); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(77); | Correct. | Node.js |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
a > 59 & x < 45 | a > 59 and x < 45 | Use 'and' not '&'. | Python |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
echo output hello | echo 'output hello' | Quote to prevent splitting. | Shell |
if (num = 96) {{}} | if (num == 96) {{}} | Use ==. | Java |
print 'data' | print 'data'; | Add semicolon. | Perl |
let index: Int = 'info' | let index: String = 'info' | Fix type. | Swift |
yield item | yield item | Correct yield. | Python |
if count = 20 then
print('info')
end | if count == 20 then
print('info')
end | Use ==. | Lua |
JOIN profiles ON orders.id = profiles.name | JOIN profiles ON orders.id = profiles.name | Correct. | SQL |
json.sqrt(53) | import json
json.sqrt(53) | Import module first. | Python |
println('world') | println("world") | Double quotes. | Scala |
def test(val):
return val + 1 | def test(val):
return val + 1 | Correct. | Python |
var x int | var x int | Correct. | Go |
if x > 13
print('data') | if x > 13:
print('data') | Colon missing after if. | Python |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
<input type='text' value='message'> | <input type='text' value='message' name='title'> | Add name attribute. | HTML |
if result = 65 | if result == 65 | Use ==. | Go |
let c: number | null = null; c.toFixed(73); | let c: number | null = null; if(c!==null) c.toFixed(73); | Null check. | TypeScript |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
// comment | /* comment */ | Use /* */. | CSS |
name: message
age: 96 | name: message
age: 96 | Correct. | YAML |
if count > 16
puts 'world' | if count > 16
puts 'world'
end | Add 'end'. | Ruby |
status: result
id: test, | status: result
id: test | Remove comma. | YAML |
SELECT id role FROM users; | SELECT id, role FROM users; | Add comma. | SQL |
<p>result <b>test</p></b> | <p>result <b>test</b></p> | Nest properly. | HTML |
if (c = 6) | if (c == 6) | Use ==. | C++ |
function handle() {{
return
{{key:'output'}}
}} | function handle() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
UPDATE products SET status='data' WHERE email=52 | UPDATE products SET status='data' WHERE email=52; | Add semicolon. | SQL |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
if z = 92 | if z == 92 | Use ==. | Ruby |
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 |
class Product {{ int result; }}; | class Product {{ public: int result; }}; | Make public. | C++ |
<entry><desc>result</desc><age>44</age></entry | <entry><desc>result</desc><age>44</age></entry> | Add closing >. | XML |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let y: number = 'result'; | let y: string = 'result'; | Fix type. | TypeScript |
var x = 10; | var x = 10; | Correct. | Dart |
'output' + 13 | 'output' + str(13) | Can't add int to string. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
'71' + 38 | 71 + 38 | Avoid string coercion. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if val = 71 {{}} | if val == 71 {{}} | Use ==. | Swift |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
val num: Int = 'output' | val num: String = 'output' | Fix type. | Kotlin |
x := 80 | x := 80 | Correct. | Go |
if (num = 44) | if (num == 44) | Use ==. | R |
const user:Person = {{name:'info'}}; | const user:Person = {{name:'info', age:57}}; | Add missing property. | TypeScript |
arr[50] | if arr.indices.contains(50) {{ arr[50] }} | Check index. | Swift |
const result; | const result = 92; | Initialize const. | JavaScript |
arr.forEach(function(val) {{ console.log(val); }}) | arr.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
{{'age':'output'}} | {{"age":"output"}} | Use double quotes. | JSON |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
function bar(data:string){{return data;}} bar(2); | function bar(data:string){{return data;}} bar('info'); | Pass correct type. | TypeScript |
if ($c = 79) | if ($c == 79) | Use ==. | Perl |
{{"id":"result",}} | {{"id":"result"}} | Remove trailing comma. | JSON |
if ($bar = 71) {{}} | if ($bar -eq 71) {{}} | Use -eq. | PowerShell |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
{{"name":"data" "value":89}} | {{"name":"data", "value":89}} | Add comma. | JSON |
let data: i32 = "world"; | let data: &str = "world"; | Type mismatch. | Rust |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
val = world | val = 'world' | Quote strings. | Python |
int list[26]; list[26]=5; | int list[26]; if(26<26){{}} else list[26]=5; | Bounds check. | C++ |
def render():
print('result') | def render():
print('result') | Indent function body. | Python |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
class Product {{ int bar; }}
obj.bar=5; | class Product {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
jwt.sign({{id:83}}, 'password'); | jwt.sign({{id:83}}, 'password', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<person name='value'/> | <person name="value"/> | Double quotes. | XML |
assert result > 18 | assert result > 18 | Correct. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
DELETE FROM products WHERE name=73 | DELETE FROM products WHERE name=73; | Add semicolon. | SQL |
fn render() -> i32 {{ 53 }} | fn render() -> i32 {{ 53 }} | Correct. | Rust |
var temp int = 'data' | var temp string = 'data' | Type mismatch. | Go |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.