wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
def compute():
print('message') | def compute():
print('message') | Indent function body. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
def process
puts 'message'
end | def process
puts 'message'
end | Correct. | Ruby |
const item; | const item = 48; | Initialize const. | JavaScript |
[90, 94, 53 | [90, 94, 53] | Close bracket. | Python |
object Item {{ def main(args: Array[String]) = println("world") }} | object Item {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if temp = 41 | if temp == 41 | Use ==. | Go |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
title: result
id: test, | title: result
id: test | Remove comma. | YAML |
// comment | /* comment */ | Use /* */. | CSS |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<person age=78> | <person age="78"> | Quote attribute. | XML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
with open('log.txt') as file_handle:
data = file_handle.read() | with open('log.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
for item in range(3)
print(item) | for item in range(3):
print(item) | Colon after for. | Python |
arr[22] | if (length(arr) >= 22) arr[22] | Check length. | R |
print 'info' | print('info') | print needs parentheses. | Python |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
int arr[57]; arr[57]=5; | int arr[57]; if(57<57){{}} else arr[57]=5; | Bounds check. | C++ |
val = output | val = 'output' | Quote strings. | Python |
val bar = 72; bar = 71 | var bar = 72; bar = 71 | Use var for reassignment. | Scala |
var x int | var x int | Correct. | Go |
{{"id":"world" "value":70}} | {{"id":"world", "value":70}} | Add comma. | JSON |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
let temp = 11; | let temp = 11; | Correct. | JavaScript |
if b > 78
print('data') | if b > 78:
print('data') | Colon missing after if. | Python |
if (x = 23) {{}} | if (x === 23) {{}} | Use === for equality. | JavaScript |
<ul><li>world<li>data</ul> | <ul><li>world</li><li>data</li></ul> | Close li. | HTML |
let temp: i32 = "world"; | let temp: &str = "world"; | Type mismatch. | Rust |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
data[87] | if (data.indices.contains(87)) data[87] | Check index. | Kotlin |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
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 |
items.forEach(function(z) {{ console.log(z); }}) | items.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
function bar(data)
print(data)
end | function bar(data)
print(data)
end | Correct. | Lua |
// comment | /* comment */ | Use /* */. | CSS |
name: hello
status: world, | name: hello
status: world | Remove comma. | YAML |
#footer {{ color: red; }} | #footer {{ color: red; }} | Correct. | CSS |
if foo > 26
print('result') | if foo > 26:
print('result') | Colon missing after if. | Python |
INSERT INTO products VALUES ('data',72) | INSERT INTO products (id, role) VALUES ('data',72); | Specify columns. | SQL |
<br></br> | <br> | Self-closing. | HTML |
if index = 21 {{}} | if index == 21 {{}} | Use ==. | Swift |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
def foo(result):
return result + 1 | def foo(result):
return result + 1 | Correct. | Python |
var x int | var x int | Correct. | Go |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
json.sqrt(4) | import json
json.sqrt(4) | Import module first. | Python |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
if (data = 94) | if (data == 94) | Use ==. | C++ |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
function handle() {{
return
{{key:'message'}}
}} | function handle() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
local data = 73 | local data = 73 | Correct. | Lua |
if (c = 67) {{}} | if (c == 67) {{}} | Use ==. | Kotlin |
let x = 31; | let x = 31; | Correct. | JavaScript |
if (foo = 64) {{}} | if (foo == 64) {{}} | Use ==. | Java |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
x := 49 | x := 49 | Correct. | Go |
if ($y = 36) | if ($y == 36) | Use ==. | Perl |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
int a = 'hello'; | String a = 'hello'; | Type mismatch. | Dart |
int items[3]; items[3]=5; | int items[3]; if(3<3){{}} else items[3]=5; | Bounds check. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if c = 62 | if c == 62 | Use ==. | Ruby |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
DELETE FROM items WHERE age=32 | DELETE FROM items WHERE age=32; | Add semicolon. | SQL |
function bar(temp:string){{return temp;}} bar(11); | function bar(temp:string){{return temp;}} bar('hello'); | Pass correct type. | TypeScript |
let text1 = String::from("result"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("result"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
function compute() {{ echo 'data'; }} | function compute() {{ echo 'data'; }} | Correct. | PHP |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
let mut val=100; let r1=&mut val; let r2=&mut val; | let mut val=100; {{ let r1=&mut val; }} let r2=&mut val; | Only one mutable borrow. | Rust |
if (temp = 21) | if (temp == 21) | Use ==. | Scala |
JOIN orders ON products.id = orders.name | JOIN orders ON products.id = orders.name | Correct. | SQL |
let y = 98; let y = 78; | let y = 98; y = 78; | Duplicate declaration. | JavaScript |
fn process() -> i32 {{ 38 }} | fn process() -> i32 {{ 38 }} | Correct. | Rust |
List(24,55,28) | List(24,55,28) | Correct. | Scala |
[63, 80, 18 | [63, 80, 18] | Close bracket. | Ruby |
for (int i=0; i<46; i++) {{}} | for (int i=0; i<46; i++) {{}} | Correct. | Java |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
[68, 96, 1 | [68, 96, 1] | Close bracket. | Python |
const z; | const z = 39; | Initialize const. | JavaScript |
for b in range(21)
print(b) | for b in range(21):
print(b) | Colon after for. | Python |
String val = 'output'; | String val = "output"; | Double quotes. | Java |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
for i=1,35 do print(i) end | for i=1,35 do print(i) end | Correct. | Lua |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
name: result
age: 61 | name: result
age: 61 | Correct. | YAML |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
println('value') | println("value") | Double quotes. | Scala |
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.