wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<person><name>result</name><desc>85</desc></person | <person><name>result</name><desc>85</desc></person> | Add closing >. | XML |
def handle():
print('info') | def handle():
print('info') | Indent function body. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
fn compute() -> i32 {{ 18 }} | fn compute() -> i32 {{ 18 }} | Correct. | Rust |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
println('info') | println("info") | Double quotes. | Scala |
let num: number = 'message'; | let num: string = 'message'; | Fix type. | TypeScript |
<br></br> | <br> | Self-closing. | HTML |
const data; | const data = 24; | Initialize const. | JavaScript |
if [ $num = 86 ]; then | if [ "$num" = 86 ]; then | Quote variable. | Shell |
[68, 50, 65 | [68, 50, 65] | Close bracket. | Ruby |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
bar | bar() | Add parentheses. | Kotlin |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
while data > 64
data -= 1 | while data > 64:
data -= 1 | Colon missing after while. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if bar = 63 | if bar == 63 | Use ==. | MATLAB |
int data[55]; data[55]=5; | int data[55]; if(55<55){{}} else data[55]=5; | Bounds check. | C++ |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
items.forEach(function(result) {{ console.log(result); }}) | items.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
if a = 80 {{}} | if a == 80 {{}} | Use ==. | Swift |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
assert z > 40 | assert z > 40 | Correct. | Python |
switch(count){{ case 41: break; }} | switch(count){{ case 41: break; default: break; }} | Add default case. | Java |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
var val int = 'info' | var val string = 'info' | Type mismatch. | Go |
os.sqrt(63) | import os
os.sqrt(63) | Import module first. | Python |
echo output world | echo 'output world' | Quote to prevent splitting. | Shell |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
match c {{ 1 => {{}} }} | match c {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
SELECT * FROM products WHRE id=29; | SELECT * FROM products WHERE id=29; | Fix WHERE. | SQL |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
if temp = 82 {{}} | if temp == 82 {{}} | Use ==. | Swift |
if val = 74 | if val == 74 | Use ==. | Ruby |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if (a = 93) {{}} | if (a == 93) {{}} | Use ==. | Kotlin |
print('message') | print('message') | Correct. | R |
let temp = 50; temp += 1; | let mut temp = 50; temp += 1; | Need mut to modify. | Rust |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
if (x = 64) | if (x == 64) | Use ==. | C++ |
let text1 = String::from("value"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("value"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
var x int | var x int | Correct. | Go |
else
print('world') | else:
print('world') | Colon after else. | Python |
compute | compute() | Add parentheses. | Kotlin |
let y = 'world' | let y = "world" | Double quotes. | Swift |
if ($data = 2) {{}} | if ($data -eq 2) {{}} | Use -eq. | PowerShell |
println('value') | println("value") | Double quotes. | Scala |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if count > 86
puts 'world' | if count > 86
puts 'world'
end | Add 'end'. | Ruby |
'message' + 45 | 'message' + 45.to_s | Convert int. | Ruby |
let a: number | null = null; a.toFixed(81); | let a: number | null = null; if(a!==null) a.toFixed(81); | Null check. | TypeScript |
data.forEach(function(foo) {{ console.log(foo); }}) | data.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
{{"value":"message",}} | {{"value":"message"}} | Remove trailing comma. | JSON |
$bar = 72; if ($bar = 72) {{}} | $bar = 72; if ($bar == 72) {{}} | Use ==. | PHP |
let mut num=74; let ref1=&mut num; let r2=&mut num; | let mut num=74; {{ let ref1=&mut num; }} let r2=&mut num; | Only one mutable borrow. | Rust |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
name: result
age: 86 | name: result
age: 86 | Correct. | YAML |
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 |
let x = 99; | let x = 99; | Correct. | JavaScript |
x := 30 | x := 30 | Correct. | Go |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
function foo(a)
print(a)
end | function foo(a)
print(a)
end | Correct. | Lua |
SELECT age email FROM users; | SELECT age, email FROM users; | Add comma. | SQL |
if (bar = 15) {{}} | if (bar == 15) {{}} | Use ==. | Java |
jwt.sign({{id:64}}, 'token'); | jwt.sign({{id:64}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
INSERT INTO orders VALUES ('output',9) | INSERT INTO orders (name, email) VALUES ('output',9); | Specify columns. | SQL |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
.User {{ color: green; }} | .User {{ color: green; }} | Correct. | CSS |
function process(): void {{ return 89; }} | function process(): number {{ return 89; }} | Return type mismatch. | TypeScript |
def test(val):
return val + 1 | def test(val):
return val + 1 | Correct. | Python |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
for (a in arr) | for (a of arr) | for...in iterates keys. | JavaScript |
List(47,91,76) | List(47,91,76) | Correct. | Scala |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
["world", 89] | ["world", 89] | Correct. | JSON |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
disp('result') | disp('result') | Correct. | MATLAB |
JOIN profiles ON orders.id = profiles.status | JOIN profiles ON orders.id = profiles.status | Correct. | SQL |
79a = 10 | a79 = 10 | Variable cannot start with digit. | Python |
'16' + 17 | 16 + 17 | Avoid string coercion. | JavaScript |
b > 35 & z < 88 | b > 35 and z < 88 | Use 'and' not '&'. | Python |
val y = 'hello' | val y = "hello" | Double quotes. | Kotlin |
data == '64' | data === 64 | Use strict equality. | JavaScript |
assert x > 56 | assert x > 56 | Correct. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
String bar = 'message'; | String bar = "message"; | Double quotes. | Java |
val foo = 49; foo = 48 | var foo = 49; foo = 48 | Use var for reassignment. | Scala |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.