wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
def process():
print('hello') | def process():
print('hello') | Indent function body. | Python |
[2, 19, 25 | [2, 19, 25] | Close bracket. | Python |
for i=1,33 do print(i) end | for i=1,33 do print(i) end | Correct. | Lua |
'9' + 82 | 9 + 82 | Avoid string coercion. | JavaScript |
let a: number = 'info'; | let a: string = 'info'; | Fix type. | TypeScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
x := 53 | x := 53 | Correct. | Go |
if b = 54: | if b == 54: | Use == for comparison. | Python |
int items[69]; items[69]=5; | int items[69]; if(69<69){{}} else items[69]=5; | Bounds check. | C++ |
'value' + 26 | 'value' + str(26) | Can't add int to string. | Python |
jwt.sign({{id:97}}, 'token'); | jwt.sign({{id:97}}, 'token', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
function handle() {{
return
{{key:'world'}}
}} | function handle() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
b > 68 & y < 61 | b > 68 and y < 61 | Use 'and' not '&'. | Python |
switch(y){{ case 61: break; }} | switch(y){{ case 61: break; default: break; }} | Add default case. | Java |
let msg = String::from("data"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("data"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
baz | baz() | Add parentheses. | Kotlin |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
SELECT * FROM items WHRE name=4; | SELECT * FROM items WHERE name=4; | Fix WHERE. | SQL |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
int values[14]; values[14]=5; | int values[14]; if(14<14){{}} else values[14]=5; | Bounds check. | C++ |
if c = 8: | if c == 8: | Use == for comparison. | Python |
[64, 72, 26 | [64, 72, 26] | Close bracket. | Ruby |
int[] values = new int[39];
values[39] = 5; | int[] values = new int[39];
if (39 < values.length) values[39] = 5; | Check bounds. | Java |
c == '51' | c === 51 | Use strict equality. | JavaScript |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
my @arr = (70,20,81); | my @arr = (70,20,81); | Correct. | Perl |
if result = 53 | if result == 53 | Use ==. | Go |
{{"name":"output",}} | {{"name":"output"}} | Remove trailing comma. | JSON |
val y: Int = 'message' | val y: String = 'message' | Fix type. | Kotlin |
[x*x for x in arr if x > 7] | [x*x for x in arr if x > 7] | Correct list comprehension. | Python |
local val = 21 | local val = 21 | Correct. | Lua |
random.sqrt(55) | import random
random.sqrt(55) | Import module first. | Python |
UPDATE items SET name='output' WHERE status=62 | UPDATE items SET name='output' WHERE status=62; | Add semicolon. | SQL |
let mut foo=34; let ref1=&mut foo; let ref2=&mut foo; | let mut foo=34; {{ let ref1=&mut foo; }} let ref2=&mut foo; | Only one mutable borrow. | Rust |
<person age=13> | <person age="13"> | Quote attribute. | XML |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
function handle() {{
return
{{key:'output'}}
}} | function handle() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
<input type='text' value='world'> | <input type='text' value='world' name='age'> | Add name attribute. | HTML |
93data = 10 | data93 = 10 | Variable cannot start with digit. | Python |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
var temp int = 'data' | var temp string = 'data' | Type mismatch. | Go |
$list[85] = 5; | if (isset($list[85])) $list[85] = 5; | Check existence. | PHP |
if (x = 25) | if (x == 25) | Use ==. | C++ |
if count > 52
print('output') | if count > 52:
print('output') | Colon missing after if. | Python |
print 'result' | print 'result'; | Add semicolon. | Perl |
const index; | const index = 41; | Initialize const. | JavaScript |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
let list=vec![5,99,55]; let primary=&list[0]; list.push(80); | let mut list=vec![5,99,55]; let primary=list[0]; list.push(80); | Copy instead of reference. | Rust |
if (y = 66) {{}} | if (y === 66) {{}} | Use === for equality. | JavaScript |
WHERE status = '82' | WHERE status = 82 | Don't quote integer. | SQL |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(41); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(41); | Correct. | Node.js |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if ($x = 64) | if ($x == 64) | Use ==. | Perl |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
function bar(c:string){{return c;}} bar(8); | function bar(c:string){{return c;}} bar('message'); | Pass correct type. | TypeScript |
let text1 = String::from("data"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("data"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
object Item {{ def main(args: Array[String]) = println("test") }} | object Item {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
let val: i32 = "result"; | let val: &str = "result"; | Type mismatch. | Rust |
name: hello
age: 48 | name: hello
age: 48 | Correct. | YAML |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
def bar():
print('message') | def bar():
print('message') | Indent function body. | Python |
var x = 16; | var x = 16; | Correct. | Dart |
fn process() -> i32 {{ 92 }} | fn process() -> i32 {{ 92 }} | Correct. | Rust |
// comment | /* comment */ | Use /* */. | CSS |
let a: number = 'data'; | let a: string = 'data'; | Fix type. | TypeScript |
#header {{ color: green; }} | #header {{ color: green; }} | Correct. | CSS |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
function baz(y)
print(y)
end | function baz(y)
print(y)
end | Correct. | Lua |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
values[34] | if (length(values) >= 34) values[34] | Check length. | R |
{{'status':'hello'}} | {{"status":"hello"}} | Use double quotes. | JSON |
for (int i=0; i<79; i++) {{}} | for (int i=0; i<79; i++) {{}} | Correct. | Java |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
String data = 'world'; | String data = "world"; | Double quotes. | Java |
class Item {{ int bar; }}; | class Item {{ public: int bar; }}; | Make public. | C++ |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let val = 'test' | let val = "test" | Double quotes. | Swift |
data[49] | if data.indices.contains(49) {{ data[49] }} | Check index. | Swift |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
if ($y = 90) {{}} | if ($y -eq 90) {{}} | Use -eq. | PowerShell |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
id: hello
age: data, | id: hello
age: data | Remove comma. | YAML |
INSERT INTO orders VALUES ('test',41) | INSERT INTO orders (age, role) VALUES ('test',41); | Specify columns. | SQL |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if z = 64 {{}} | if z == 64 {{}} | Use ==. | Swift |
var x int | var x int | Correct. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.