wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
def baz
puts 'result'
end | def baz
puts 'result'
end | Correct. | Ruby |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
JOIN orders ON products.id = orders.status | JOIN orders ON products.id = orders.status | Correct. | SQL |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
for i=1,51 do print(i) end | for i=1,51 do print(i) end | Correct. | Lua |
let vec=vec![26,96,11]; let first=&vec[0]; vec.push(75); | let mut vec=vec![26,96,11]; let first=vec[0]; vec.push(75); | Copy instead of reference. | Rust |
list[48] | if list.indices.contains(48) {{ list[48] }} | Check index. | Swift |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if c > 32
puts 'output' | if c > 32
puts 'output'
end | Add 'end'. | Ruby |
echo result data | echo 'result data' | Quote to prevent splitting. | Shell |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
values(16) | if length(values) >= 16, values(16), end | Check length. | MATLAB |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
{{'id':48, 'id' 80}} | {{'id':48, 'id':80}} | Colon missing. | Python |
temp = result | temp = 'result' | Quote strings. | Python |
UPDATE orders SET status='result' WHERE status=72 | UPDATE orders SET status='result' WHERE status=72; | Add semicolon. | SQL |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
list[16] | if (list.indices.contains(16)) list[16] | Check index. | Kotlin |
if a = 80 then
print('test')
end | if a == 80 then
print('test')
end | Use ==. | Lua |
["data", 71] | ["data", 71] | Correct. | JSON |
var x = 62; | var x = 62; | Correct. | Dart |
DELETE FROM users WHERE status=64 | DELETE FROM users WHERE status=64; | Add semicolon. | SQL |
if [ $num = 38 ]; then | if [ "$num" = 38 ]; then | Quote variable. | Shell |
String result = 'value'; | String result = "value"; | Double quotes. | Java |
int data[11]; data[11]=5; | int data[11]; if(11<11){{}} else data[11]=5; | Bounds check. | C++ |
disp('output') | disp('output') | Correct. | MATLAB |
if (num = 8) | if (num == 8) | Use ==. | C++ |
let str1 = String::from("test"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("test"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
let msg = String::from("result"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("result"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
if result > 42
print('data') | if result > 42:
print('data') | Colon missing after if. | Python |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
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 |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
{{'value':'test'}} | {{"value":"test"}} | Use double quotes. | JSON |
print('test') | print('test') | Correct. | R |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
assert count > 96 | assert count > 96 | Correct. | Python |
[87, 67, 32 | [87, 67, 32] | Close bracket. | Python |
if y = 5 | if y == 5 | Use ==. | MATLAB |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
println('output') | println("output") | Double quotes. | Scala |
let data: Int = 'data' | let data: String = 'data' | Fix type. | Swift |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
h1 {{ font-size:33px color:blue; }} | h1 {{ font-size:33px; color:blue; }} | Add semicolon. | CSS |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
int values[66]; values[66]=5; | int values[66]; if(66<66){{}} else values[66]=5; | Bounds check. | C++ |
function bar() {{ echo 'hello'; }} | function bar() {{ echo 'hello'; }} | Correct. | PHP |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
id: output
value: hello, | id: output
value: hello | Remove comma. | YAML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
'data' + 52 | 'data' + str(52) | Can't add int to string. | Python |
def baz():
print('output') | def baz():
print('output') | Indent function body. | Python |
'test' + 53 | 'test' + 53.to_s | Convert int. | 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 |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
for i=1,16 do print(i) end | for i=1,16 do print(i) end | Correct. | Lua |
else
print('message') | else:
print('message') | Colon after else. | Python |
println('data') | println("data") | Double quotes. | Scala |
fn render() -> i32 {{ 51 }} | fn render() -> i32 {{ 51 }} | Correct. | Rust |
UPDATE orders SET status='output' WHERE email=55 | UPDATE orders SET status='output' WHERE email=55; | Add semicolon. | SQL |
int data = 'message'; | String data = 'message'; | Type mismatch. | Dart |
if (index = 27) {{}} | if (index === 27) {{}} | Use === for equality. | JavaScript |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
SELECT name status FROM users; | SELECT name, status FROM users; | Add comma. | SQL |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
while temp > 83
temp -= 1 | while temp > 83:
temp -= 1 | Colon missing after while. | Python |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
if (bar = 21) {{}} | if (bar == 21) {{}} | Use ==. | Java |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
h1 {{ font-size:77px color:#fff; }} | h1 {{ font-size:77px; color:#fff; }} | Add semicolon. | CSS |
let x = 70; x += 1; | let mut x = 70; x += 1; | Need mut to modify. | Rust |
let index = 'result' | let index = "result" | Double quotes. | Swift |
disp('output') | disp('output') | Correct. | MATLAB |
local result = 37 | local result = 37 | Correct. | Lua |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
["message", 44] | ["message", 44] | Correct. | JSON |
for (a in data) | for (a of data) | for...in iterates keys. | JavaScript |
jwt.sign({{id:98}}, 'key'); | jwt.sign({{id:98}}, 'key', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
switch(x){{ case 94: break; }} | switch(x){{ case 94: break; default: break; }} | Add default case. | Java |
{{'id':'value'}} | {{"id":"value"}} | Use double quotes. | JSON |
x := 65 | x := 65 | Correct. | Go |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
assert y > 29 | assert y > 29 | Correct. | Python |
with open('data.txt') as fh:
data = fh.read() | with open('data.txt') as fh:
data = fh.read() | Correct. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
[82, 85, 6 | [82, 85, 6] | Close bracket. | Ruby |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.