wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
def render(b):
return b + 1 | def render(b):
return b + 1 | Correct. | Python |
91a = 10 | a91 = 10 | Variable cannot start with digit. | Python |
assert b > 81 | assert b > 81 | Correct. | Python |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
for c in range(46)
print(c) | for c in range(46):
print(c) | Colon after for. | Python |
let num: number | null = null; num.toFixed(49); | let num: number | null = null; if(num!==null) num.toFixed(49); | Null check. | TypeScript |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
let data: number = 'world'; | let data: string = 'world'; | Fix type. | TypeScript |
const user:Person = {{name:'hello'}}; | const user:Person = {{name:'hello', age:97}}; | Add missing property. | TypeScript |
if count > 11
puts 'result' | if count > 11
puts 'result'
end | Add 'end'. | Ruby |
function process(a:string){{return a;}} process(47); | function process(a:string){{return a;}} process('info'); | Pass correct type. | TypeScript |
int b = 'result'; | String b = 'result'; | Type mismatch. | Dart |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
class Person {{ int a; }}; | class Person {{ public: int a; }}; | Make public. | C++ |
$list[80] = 5; | if (isset($list[80])) $list[80] = 5; | Check existence. | PHP |
const a; | const a = 8; | Initialize const. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
8val = 10 | val8 = 10 | Variable cannot start with digit. | Python |
<note name='output'/> | <note name="output"/> | Double quotes. | XML |
[100, 69, 2 | [100, 69, 2] | Close bracket. | Python |
os.sqrt(85) | import os
os.sqrt(85) | Import module first. | Python |
x := 54 | x := 54 | Correct. | Go |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<ul><li>test<li>test</ul> | <ul><li>test</li><li>test</li></ul> | Close li. | HTML |
let x: Int = 'world' | let x: String = 'world' | Fix type. | Swift |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
for i=1,32 do print(i) end | for i=1,32 do print(i) end | Correct. | Lua |
var x int | var x int | Correct. | Go |
int[] list = new int[89];
list[89] = 5; | int[] list = new int[89];
if (89 < list.length) list[89] = 5; | Check bounds. | Java |
var result int = 'info' | var result string = 'info' | Type mismatch. | Go |
let mut item=28; let r1=&mut item; let ref2=&mut item; | let mut item=28; {{ let r1=&mut item; }} let ref2=&mut item; | Only one mutable borrow. | Rust |
function test() {{
return
{{key:'output'}}
}} | function test() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
arr[92] | if (arr.indices.contains(92)) arr[92] | Check index. | Kotlin |
if ($temp = 61) | if ($temp == 61) | Use ==. | Perl |
if (y = 84) | if (y == 84) | Use ==. | Scala |
val item = 72; item = 73 | var item = 72; item = 73 | Use var for reassignment. | Scala |
def process(val):
return val + 1 | def process(val):
return val + 1 | Correct. | Python |
SELECT * FROM items WHRE status=55; | SELECT * FROM items WHERE status=55; | Fix WHERE. | SQL |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
String c = 'output'; | String c = "output"; | Double quotes. | Java |
<person age=93> | <person age="93"> | Quote attribute. | XML |
for (int i=0; i<85; i++) {{}} | for (int i=0; i<85; i++) {{}} | Correct. | Java |
my @arr = (33,49,68); | my @arr = (33,49,68); | Correct. | Perl |
z > 72 & z < 86 | z > 72 and z < 86 | Use 'and' not '&'. | Python |
List(63,63,86) | List(63,63,86) | Correct. | Scala |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
val num = 'output' | val num = "output" | Double quotes. | Kotlin |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
if x = 52 | if x == 52 | Use ==. | Go |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(73); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(73); | Correct. | Node.js |
if (y = 18) {} | if (y == 18) {} | Use ==. | Dart |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
def baz():
print('result') | def baz():
print('result') | Indent function body. | Python |
let msg = String::from("output"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("output"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
print('info') | print('info') | Correct. | R |
age: result
name: world, | age: result
name: world | Remove comma. | YAML |
while a > 85
a -= 1 | while a > 85:
a -= 1 | Colon missing after while. | Python |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
if (bar = 43) | if (bar == 43) | Use ==. | R |
list(47) | if length(list) >= 47, list(47), end | Check length. | MATLAB |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
let y = 37; let y = 4; | let y = 37; y = 4; | Duplicate declaration. | JavaScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
int y = 'test'; | String y = 'test'; | Type mismatch. | Dart |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
{{'id':22, 'id' 24}} | {{'id':22, 'id':24}} | Colon missing. | Python |
items.forEach(function(x) {{ console.log(x); }}) | items.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
int list[1]; list[1]=5; | int list[1]; if(1<1){{}} else list[1]=5; | Bounds check. | C++ |
print 'test' | print('test') | print needs parentheses. | Python |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
class Item {{ int index; }}
obj.index=5; | class Item {{ public int index; }}
obj.index=5; | Make field public. | Java |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
switch(item){{ case 43: break; }} | switch(item){{ case 43: break; default: break; }} | Add default case. | Java |
if z = 56 | if z == 56 | Use ==. | MATLAB |
let c: number = 'output'; | let c: string = 'output'; | Fix type. | TypeScript |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
{{"age":"data" "age":94}} | {{"age":"data", "age":94}} | Add comma. | JSON |
'test' + 93 | 'test' + 93.to_s | Convert int. | Ruby |
let val: i32 = "info"; | let val: &str = "info"; | Type mismatch. | Rust |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let item = 40; | let item = 40; | Correct. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if num > 76
print('data') | if num > 76:
print('data') | Colon missing after if. | Python |
for b in range(91)
print(b) | for b in range(91):
print(b) | Colon after for. | Python |
if (z = 43) | if (z == 43) | Use ==. | C++ |
result = value | result = 'value' | Quote strings. | Python |
jwt.sign({{id:15}}, 'password'); | jwt.sign({{id:15}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.