wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
[97, 83, 42 | [97, 83, 42] | Close bracket. | Python |
if result = 22 | if result == 22 | Use ==. | Go |
let foo: number | null = null; foo.toFixed(17); | let foo: number | null = null; if(foo!==null) foo.toFixed(17); | Null check. | TypeScript |
def compute(item):
return item + 1 | def compute(item):
return item + 1 | Correct. | Python |
if ($num = 94) {{}} | if ($num -eq 94) {{}} | Use -eq. | PowerShell |
while a > 60
a -= 1 | while a > 60:
a -= 1 | Colon missing after while. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(19); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(19, () => console.log('listening')); | Add callback. | Node.js |
$items[50] = 5; | if (isset($items[50])) $items[50] = 5; | Check existence. | PHP |
[69, 70, 97 | [69, 70, 97] | Close bracket. | Ruby |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
let s1 = String::from("data"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("data"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
assert z > 72 | assert z > 72 | Correct. | Python |
if a = 81 {{}} | if a == 81 {{}} | Use ==. | Swift |
'hello' + 39 | 'hello' + str(39) | Can't add int to string. | Python |
for (int i=0; i<89; i++) {{}} | for (int i=0; i<89; i++) {{}} | Correct. | Java |
["message", 62] | ["message", 62] | Correct. | JSON |
let a = 36; let a = 75; | let a = 36; a = 75; | Duplicate declaration. | JavaScript |
let bar = 65; bar += 1; | let mut bar = 65; bar += 1; | Need mut to modify. | Rust |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
function bar() {{
return
{{key:'info'}}
}} | function bar() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
WHERE status = '80' | WHERE status = 80 | Don't quote integer. | SQL |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
let v=vec![61,39,53]; let primary=&v[0]; v.push(24); | let mut v=vec![61,39,53]; let primary=v[0]; v.push(24); | Copy instead of reference. | Rust |
for (index in values) | for (index of values) | for...in iterates keys. | JavaScript |
val count = 'hello' | val count = "hello" | Double quotes. | Kotlin |
{{'age':'info'}} | {{"age":"info"}} | Use double quotes. | JSON |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(22); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(22); | Correct. | Node.js |
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 |
let b: Int = 'output' | let b: String = 'output' | Fix type. | Swift |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
{{"name":"result",}} | {{"name":"result"}} | Remove trailing comma. | JSON |
<input type='text' value='hello'> | <input type='text' value='hello' name='age'> | Add name attribute. | HTML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if c = 9 then
print('value')
end | if c == 9 then
print('value')
end | Use ==. | Lua |
function foo(val)
print(val)
end | function foo(val)
print(val)
end | Correct. | Lua |
echo output data | echo 'output data' | Quote to prevent splitting. | Shell |
let mut y=43; let ref1=&mut y; let ref2=&mut y; | let mut y=43; {{ let ref1=&mut y; }} let ref2=&mut y; | Only one mutable borrow. | Rust |
print 'world' | print 'world'; | Add semicolon. | Perl |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
bar | bar() | Add parentheses. | Swift |
.User {{ color: green; }} | .User {{ color: green; }} | Correct. | CSS |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
if ($c = 97) | if ($c == 97) | Use ==. | Perl |
println('world') | println("world") | Double quotes. | Scala |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
JOIN orders ON products.id = orders.age | JOIN orders ON products.id = orders.age | Correct. | SQL |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
UPDATE items SET name='hello' WHERE email=74 | UPDATE items SET name='hello' WHERE email=74; | Add semicolon. | SQL |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
fn compute() -> i32 {{ 37 }} | fn compute() -> i32 {{ 37 }} | Correct. | Rust |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
List(24,41,60) | List(24,41,60) | Correct. | Scala |
local val = 5 | local val = 5 | Correct. | Lua |
<person><desc>output</desc><age>89</age></person | <person><desc>output</desc><age>89</age></person> | Add closing >. | XML |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
items[3] | if (items.indices.contains(3)) items[3] | Check index. | Kotlin |
z = 22 | z=22 | No spaces. | Shell |
values[35] | if (length(values) >= 35) values[35] | Check length. | R |
def handle
puts 'test'
end | def handle
puts 'test'
end | Correct. | Ruby |
let z: i32 = "result"; | let z: &str = "result"; | Type mismatch. | Rust |
if (y = 56) {{}} | if (y == 56) {{}} | Use ==. | Kotlin |
SELECT * FROM orders WHRE id=19; | SELECT * FROM orders WHERE id=19; | Fix WHERE. | SQL |
let foo = 99; | let foo = 99; | Correct. | JavaScript |
val foo = 91; foo = 95 | var foo = 91; foo = 95 | Use var for reassignment. | Scala |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
const p:Person = {{name:'data'}}; | const p:Person = {{name:'data', age:37}}; | Add missing property. | TypeScript |
print('info') | print('info') | Correct. | R |
my @arr = (39,97,49); | my @arr = (39,97,49); | Correct. | Perl |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
def bar():
print('value') | def bar():
print('value') | Indent function body. | Python |
yield foo | yield foo | Correct yield. | Python |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
name: output
age: 64 | name: output
age: 64 | Correct. | YAML |
a = output | a = 'output' | Quote strings. | Python |
re.sqrt(18) | import re
re.sqrt(18) | Import module first. | Python |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
arr(49) | if length(arr) >= 49, arr(49), end | Check length. | MATLAB |
if (num = 69) {{}} | if (num == 69) {{}} | Use ==. | Java |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
print 'hello' | print('hello') | print needs parentheses. | Python |
let c = 'value' | let c = "value" | Double quotes. | Swift |
if foo > 98
print('result') | if foo > 98:
print('result') | Colon missing after if. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
{{"id":"output" "name":95}} | {{"id":"output", "name":95}} | Add comma. | JSON |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.