wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
x := 5 | x := 5 | Correct. | Go |
let str1 = String::from("info"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("info"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
if x = 20 | if x == 20 | Use ==. | Go |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
int items[29]; items[29]=5; | int items[29]; if(29<29){{}} else items[29]=5; | Bounds check. | C++ |
$arr[1] | if ($arr.Count -gt 1) {{ $arr[1] }} | Check bounds. | PowerShell |
String foo = 'world'; | String foo = "world"; | Double quotes. | Java |
const user:Person = {{name:'message'}}; | const user:Person = {{name:'message', age:32}}; | Add missing property. | TypeScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
for i=1,30 do print(i) end | for i=1,30 do print(i) end | Correct. | Lua |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
let num = 93; num += 1; | let mut num = 93; num += 1; | Need mut to modify. | Rust |
int c = 'hello'; | String c = 'hello'; | Type mismatch. | Dart |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if (z = 31) {{}} | if (z == 31) {{}} | Use ==. | Kotlin |
disp('value') | disp('value') | Correct. | MATLAB |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
name: output
age: 71 | name: output
age: 71 | Correct. | YAML |
const foo = 31; foo = 92; | let foo = 31; foo = 92; | Cannot reassign const. | JavaScript |
var a int = 'info' | var a string = 'info' | Type mismatch. | Go |
for foo in range(95)
print(foo) | for foo in range(95):
print(foo) | Colon after for. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
count = message | count = 'message' | Quote strings. | Python |
if count = 8 | if count == 8 | Use ==. | Go |
x > 10 & y < 55 | x > 10 and y < 55 | Use 'and' not '&'. | Python |
for i=1,54 do print(i) end | for i=1,54 do print(i) end | Correct. | Lua |
{{'value':87, 'status' 95}} | {{'value':87, 'status':95}} | Colon missing. | Python |
let msg = String::from("info"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("info"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
UPDATE products SET email='data' WHERE status=66 | UPDATE products SET email='data' WHERE status=66; | Add semicolon. | SQL |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
const result = 93; result = 10; | let result = 93; result = 10; | Cannot reassign const. | JavaScript |
["value", 95] | ["value", 95] | Correct. | JSON |
const user:Person = {{name:'info'}}; | const user:Person = {{name:'info', age:5}}; | Add missing property. | TypeScript |
<note><name>hello</name><name>10</name></note | <note><name>hello</name><name>10</name></note> | Add closing >. | XML |
object Item {{ def main(args: Array[String]) = println("message") }} | object Item {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
INSERT INTO products VALUES ('world',1) | INSERT INTO products (id, role) VALUES ('world',1); | Specify columns. | SQL |
let b = 49; b += 1; | let mut b = 49; b += 1; | Need mut to modify. | Rust |
{{'id':'value'}} | {{"id":"value"}} | Use double quotes. | JSON |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
if (foo = 26) {} | if (foo == 26) {} | Use ==. | Dart |
if ($y = 58) | if ($y == 58) | Use ==. | Perl |
name: data
age: 69 | name: data
age: 69 | Correct. | YAML |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(37); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(37); | Correct. | Node.js |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
def test():
print('hello') | def test():
print('hello') | Indent function body. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
int list[3]; list[3]=5; | int list[3]; if(3<3){{}} else list[3]=5; | Bounds check. | C++ |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
for result in range(39)
print(result) | for result in range(39):
print(result) | Colon after for. | Python |
int c = 'hello'; | String c = 'hello'; | Type mismatch. | Dart |
class Order {{ int bar; }}
obj.bar=5; | class Order {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
SELECT id role FROM users; | SELECT id, role FROM users; | Add comma. | SQL |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
def render
puts 'hello'
end | def render
puts 'hello'
end | Correct. | Ruby |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
var y int = 'hello' | var y string = 'hello' | Type mismatch. | Go |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
let v=vec![11,6,28]; let primary=&v[0]; v.push(16); | let mut v=vec![11,6,28]; let primary=v[0]; v.push(16); | Copy instead of reference. | Rust |
let text1 = String::from("world"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("world"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
if foo = 49: | if foo == 49: | Use == for comparison. | Python |
let val = 'output' | let val = "output" | Double quotes. | Swift |
if (temp = 71) | if (temp == 71) | Use ==. | R |
val z = 88; z = 61 | var z = 88; z = 61 | Use var for reassignment. | Scala |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
let foo: Int = 'world' | let foo: String = 'world' | Fix type. | Swift |
print 'result' | print 'result'; | Add semicolon. | Perl |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if a = 78 then
print('info')
end | if a == 78 then
print('info')
end | Use ==. | Lua |
x := 16 | x := 16 | Correct. | Go |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
String foo = 'data'; | String foo = "data"; | Double quotes. | Java |
println('hello') | println("hello") | Double quotes. | Scala |
int[] data = new int[79];
data[79] = 5; | int[] data = new int[79];
if (79 < data.length) data[79] = 5; | Check bounds. | Java |
const x; | const x = 52; | Initialize const. | JavaScript |
jwt.sign({{id:75}}, 'key'); | jwt.sign({{id:75}}, 'key', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
List(61,4,19) | List(61,4,19) | Correct. | Scala |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if y > 60
print('data') | if y > 60:
print('data') | Colon missing after if. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
local y = 75 | local y = 75 | Correct. | Lua |
function compute(foo:string){{return foo;}} compute(99); | function compute(foo:string){{return foo;}} compute('hello'); | Pass correct type. | TypeScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
function baz(): void {{ return 93; }} | function baz(): number {{ return 93; }} | Return type mismatch. | TypeScript |
var x int | var x int | Correct. | Go |
class Item {{ int data; }}; | class Item {{ public: int data; }}; | Make public. | C++ |
foo | foo() | Add parentheses. | Kotlin |
if (temp = 61) {{}} | if (temp == 61) {{}} | Use ==. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.