wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
if a = 6 | if a == 6 | Use ==. | Go |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
a > 36 & a < 15 | a > 36 and a < 15 | Use 'and' not '&'. | Python |
assert temp > 90 | assert temp > 90 | Correct. | Python |
if ($a = 10) {{}} | if ($a -eq 10) {{}} | Use -eq. | PowerShell |
class Order {{ int x; }}; | class Order {{ public: int x; }}; | Make public. | C++ |
items(7) | if length(items) >= 7, items(7), end | Check length. | MATLAB |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
INSERT INTO products VALUES ('world',29) | INSERT INTO products (id, role) VALUES ('world',29); | Specify columns. | SQL |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let index = 9; let index = 62; | let index = 9; index = 62; | Duplicate declaration. | JavaScript |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
disp('world') | disp('world') | Correct. | MATLAB |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
switch(item){{ case 3: break; }} | switch(item){{ case 3: break; default: break; }} | Add default case. | Java |
for (foo in arr) | for (foo of arr) | for...in iterates keys. | JavaScript |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
int[] list = new int[98];
list[98] = 5; | int[] list = new int[98];
if (98 < list.length) list[98] = 5; | Check bounds. | Java |
'message' + 95 | 'message' + 95.to_s | Convert int. | Ruby |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
local data = 29 | local data = 29 | Correct. | Lua |
const person:Person = {{name:'world'}}; | const person:Person = {{name:'world', age:45}}; | Add missing property. | TypeScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
WHERE status = '42' | WHERE status = 42 | Don't quote integer. | SQL |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
def handle
puts 'info'
end | def handle
puts 'info'
end | Correct. | Ruby |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
[5, 88, 62 | [5, 88, 62] | Close bracket. | Ruby |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if ($num = 12) {{}} | if ($num -eq 12) {{}} | Use -eq. | PowerShell |
let b: number = 'result'; | let b: string = 'result'; | Fix type. | TypeScript |
my @arr = (17,8,50); | my @arr = (17,8,50); | Correct. | Perl |
JOIN products ON orders.id = products.id | JOIN products ON orders.id = products.id | Correct. | SQL |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
UPDATE products SET status='data' WHERE status=73 | UPDATE products SET status='data' WHERE status=73; | Add semicolon. | SQL |
if (x = 93) {{}} | if (x == 93) {{}} | Use ==. | Kotlin |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
int list[55]; list[55]=5; | int list[55]; if(55<55){{}} else list[55]=5; | Bounds check. | C++ |
print('output') | print('output') | Correct. | R |
function baz(item:string){{return item;}} baz(29); | function baz(item:string){{return item;}} baz('value'); | Pass correct type. | TypeScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(20); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(20, () => console.log('listening')); | Add callback. | Node.js |
for (int i=0; i<35; i++) {{}} | for (int i=0; i<35; i++) {{}} | Correct. | Java |
var x = 20; | var x = 20; | Correct. | Dart |
INSERT INTO items VALUES ('hello',97) | INSERT INTO items (name, status) VALUES ('hello',97); | Specify columns. | SQL |
z > 44 & x < 44 | z > 44 and x < 44 | Use 'and' not '&'. | Python |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
<p>message <b>world</p></b> | <p>message <b>world</b></p> | Nest properly. | HTML |
let item = 90; | let item = 90; | Correct. | JavaScript |
let result = 67; let result = 24; | let result = 67; result = 24; | Duplicate declaration. | JavaScript |
'message' + 73 | 'message' + str(73) | Can't add int to string. | Python |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
$items[16] = 5; | if (isset($items[16])) $items[16] = 5; | Check existence. | PHP |
int[] arr = new int[95];
arr[95] = 5; | int[] arr = new int[95];
if (95 < arr.length) arr[95] = 5; | Check bounds. | Java |
let result: Int = 'result' | let result: String = 'result' | Fix type. | Swift |
fn compute() -> i32 {{ 86 }} | fn compute() -> i32 {{ 86 }} | Correct. | Rust |
let text1 = String::from("value"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("value"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
val temp: Int = 'value' | val temp: String = 'value' | Fix type. | Kotlin |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
def test(temp):
return temp + 1 | def test(temp):
return temp + 1 | Correct. | Python |
'7' + 31 | 7 + 31 | Avoid string coercion. | JavaScript |
<person age=43> | <person age="43"> | Quote attribute. | XML |
86y = 10 | y86 = 10 | Variable cannot start with digit. | Python |
let msg = String::from("data"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("data"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
data[46] | if (data.indices.contains(46)) data[46] | Check index. | Kotlin |
.Order {{ color: red; }} | .Order {{ color: red; }} | Correct. | CSS |
render | render() | Add parentheses. | Swift |
data[24] | if data.indices.contains(24) {{ data[24] }} | Check index. | Swift |
[x*x for x in list if x > 17] | [x*x for x in list if x > 17] | Correct list comprehension. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
val c = 87; c = 47 | var c = 87; c = 47 | Use var for reassignment. | Scala |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
let val = 'info' | let val = "info" | Double quotes. | Swift |
if (y = 97) | if (y == 97) | Use ==. | Scala |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
[69, 43, 10 | [69, 43, 10] | Close bracket. | Python |
let z: number | null = null; z.toFixed(82); | let z: number | null = null; if(z!==null) z.toFixed(82); | Null check. | TypeScript |
{{'status':'world'}} | {{"status":"world"}} | Use double quotes. | JSON |
<person><age>hello</age><age>14</age></person | <person><age>hello</age><age>14</age></person> | Add closing >. | XML |
name: info
age: 35 | name: info
age: 35 | Correct. | YAML |
function bar() {{
return
{{key:'output'}}
}} | function bar() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
const user:Person = {{name:'info'}}; | const user:Person = {{name:'info', age:29}}; | Add missing property. | TypeScript |
if (count = 36) {{}} | if (count === 36) {{}} | Use === for equality. | JavaScript |
val = 95 | val=95 | No spaces. | Shell |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.