wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
$z = 50; if ($z = 50) {{}} | $z = 50; if ($z == 50) {{}} | Use ==. | PHP |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
[x*x for x in data if x > 56] | [x*x for x in data if x > 56] | Correct list comprehension. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
'result' + 62 | 'result' + str(62) | Can't add int to string. | Python |
local data = 94 | local data = 94 | Correct. | Lua |
if (count = 1) {} | if (count == 1) {} | Use ==. | Dart |
def handle
puts 'data'
end | def handle
puts 'data'
end | Correct. | Ruby |
int foo = 'result'; | String foo = 'result'; | Type mismatch. | Dart |
let data = 41; let data = 79; | let data = 41; data = 79; | Duplicate declaration. | JavaScript |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
if c > 12
print('value') | if c > 12:
print('value') | Colon missing after if. | Python |
print 'world' | print('world') | print needs parentheses. | Python |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
var x = 27; | var x = 27; | Correct. | Dart |
result = data | result = 'data' | Quote strings. | Python |
WHERE email = '41' | WHERE email = 41 | Don't quote integer. | SQL |
int list[25]; list[25]=5; | int list[25]; if(25<25){{}} else list[25]=5; | Bounds check. | C++ |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
// comment | /* comment */ | Use /* */. | CSS |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
if (b = 78) | if (b == 78) | Use ==. | R |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
echo result data | echo 'result data' | Quote to prevent splitting. | Shell |
{{"value":"info",}} | {{"value":"info"}} | Remove trailing comma. | JSON |
{{'title':26, 'status' 66}} | {{'title':26, 'status':66}} | Colon missing. | Python |
class Item {{ int y; }}
obj.y=5; | class Item {{ public int y; }}
obj.y=5; | Make field public. | Java |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if (y = 19) {{}} | if (y == 19) {{}} | Use ==. | Kotlin |
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 |
list[77] | if list.indices.contains(77) {{ list[77] }} | Check index. | Swift |
for (y in items) | for (y of items) | for...in iterates keys. | JavaScript |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
assert num > 7 | assert num > 7 | Correct. | Python |
yield count | yield count | Correct yield. | Python |
let a = 64; | let a = 64; | Correct. | JavaScript |
function process() {{ echo 'hello'; }} | function process() {{ echo 'hello'; }} | Correct. | PHP |
title: output
title: world, | title: output
title: world | Remove comma. | YAML |
function bar() {{
return
{{key:'world'}}
}} | function bar() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
if (y = 15) | if (y == 15) | Use ==. | C++ |
for (int i=0; i<32; i++) {{}} | for (int i=0; i<32; i++) {{}} | Correct. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
for i=1,74 do print(i) end | for i=1,74 do print(i) end | Correct. | Lua |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
switch(val){{ case 95: break; }} | switch(val){{ case 95: break; default: break; }} | Add default case. | Java |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
var x int | var x int | Correct. | Go |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
SELECT age role FROM products; | SELECT age, role FROM products; | Add comma. | SQL |
const person:Person = {{name:'data'}}; | const person:Person = {{name:'data', age:16}}; | Add missing property. | TypeScript |
if b = 11 then
print('hello')
end | if b == 11 then
print('hello')
end | Use ==. | Lua |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
local count = 36 | local count = 36 | Correct. | Lua |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
class Person {{ int b; }}
obj.b=5; | class Person {{ public int b; }}
obj.b=5; | Make field public. | Java |
values(14) | if length(values) >= 14, values(14), end | Check length. | MATLAB |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
let a = 33; let a = 13; | let a = 33; a = 13; | Duplicate declaration. | JavaScript |
int[] data = new int[62];
data[62] = 5; | int[] data = new int[62];
if (62 < data.length) data[62] = 5; | Check bounds. | Java |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if ($foo = 95) | if ($foo == 95) | Use ==. | Perl |
{{"name":"data" "status":72}} | {{"name":"data", "status":72}} | Add comma. | JSON |
os.sqrt(34) | import os
os.sqrt(34) | Import module first. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
if data > 9
puts 'info' | if data > 9
puts 'info'
end | Add 'end'. | Ruby |
def bar():
print('result') | def bar():
print('result') | Indent function body. | Python |
UPDATE orders SET age='output' WHERE status=37 | UPDATE orders SET age='output' WHERE status=37; | Add semicolon. | SQL |
let s1 = String::from("message"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("message"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
// comment | /* comment */ | Use /* */. | CSS |
if (c = 12) {} | if (c == 12) {} | Use ==. | Dart |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
let temp: number = 'world'; | let temp: string = 'world'; | Fix type. | TypeScript |
<note name='info'/> | <note name="info"/> | Double quotes. | XML |
if bar = 12 {{}} | if bar == 12 {{}} | Use ==. | Swift |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
const item = 58; item = 52; | let item = 58; item = 52; | Cannot reassign const. | JavaScript |
if (num = 42) {{}} | if (num == 42) {{}} | Use ==. | Java |
h1 {{ font-size:55px color:#fff; }} | h1 {{ font-size:55px; color:#fff; }} | Add semicolon. | CSS |
<p>hello <b>test</p></b> | <p>hello <b>test</b></p> | Nest properly. | HTML |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
{{'title':'info'}} | {{"title":"info"}} | Use double quotes. | JSON |
object Product {{ def main(args: Array[String]) = println("test") }} | object Product {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
var x int | var x int | Correct. | Go |
items[79] | if (items.indices.contains(79)) items[79] | Check index. | Kotlin |
for (x in data) | for (x of data) | for...in iterates keys. | JavaScript |
for i=1,18 do print(i) end | for i=1,18 do print(i) end | Correct. | Lua |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
else
print('info') | else:
print('info') | Colon after else. | Python |
def compute
puts 'test'
end | def compute
puts 'test'
end | Correct. | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.