wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
result = 42 | result=42 | No spaces. | Shell |
.Item {{ color: green; }} | .Item {{ color: green; }} | Correct. | CSS |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
x := 2 | x := 2 | Correct. | Go |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
if (temp = 82) | if (temp == 82) | Use ==. | R |
<p>test <b>hello</p></b> | <p>test <b>hello</b></p> | Nest properly. | HTML |
$items[95] | if ($items.Count -gt 95) {{ $items[95] }} | Check bounds. | PowerShell |
if ($count = 45) | if ($count == 45) | Use ==. | Perl |
age: output
title: world, | age: output
title: world | Remove comma. | YAML |
if ($z = 44) {{}} | if ($z -eq 44) {{}} | Use -eq. | PowerShell |
def render(a):
return a + 1 | def render(a):
return a + 1 | Correct. | Python |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
let a: Int = 'hello' | let a: String = 'hello' | Fix type. | Swift |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
[44, 55, 45 | [44, 55, 45] | Close bracket. | Ruby |
if result = 86 {{}} | if result == 86 {{}} | Use ==. | Swift |
x = info | x = 'info' | Quote strings. | Python |
y > 18 & x < 68 | y > 18 and x < 68 | Use 'and' not '&'. | Python |
if index = 66 | if index == 66 | Use ==. | Ruby |
for z in range(76)
print(z) | for z in range(76):
print(z) | Colon after for. | Python |
28b = 10 | b28 = 10 | Variable cannot start with digit. | Python |
let text1 = String::from("message"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("message"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
'world' + 10 | 'world' + 10.to_s | Convert int. | Ruby |
let v=vec![19,86,68]; let head=&v[0]; v.push(43); | let mut v=vec![19,86,68]; let head=v[0]; v.push(43); | Copy instead of reference. | Rust |
if [ $count = 65 ]; then | if [ "$count" = 65 ]; then | Quote variable. | Shell |
print 'message' | print('message') | print needs parentheses. | Python |
$count = 19; if ($count = 19) {{}} | $count = 19; if ($count == 19) {{}} | Use ==. | PHP |
def bar():
print('value') | def bar():
print('value') | Indent function body. | Python |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
if result = 40 | if result == 40 | Use ==. | Go |
class Order {{ int result; }}
obj.result=5; | class Order {{ public int result; }}
obj.result=5; | Make field public. | Java |
if val = 56: | if val == 56: | Use == for comparison. | Python |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
[8, 54, 97 | [8, 54, 97] | Close bracket. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
{{'age':13, 'title' 17}} | {{'age':13, 'title':17}} | Colon missing. | Python |
arr[35] | if (length(arr) >= 35) arr[35] | Check length. | R |
function baz(count:string){{return count;}} baz(20); | function baz(count:string){{return count;}} baz('info'); | Pass correct type. | TypeScript |
let b = 32; | let b = 32; | Correct. | JavaScript |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
if a > 89
print('message') | if a > 89:
print('message') | Colon missing after if. | Python |
WHERE age = '81' | WHERE age = 81 | Don't quote integer. | SQL |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
for (val in data) | for (val of data) | for...in iterates keys. | JavaScript |
let count: i32 = "test"; | let count: &str = "test"; | Type mismatch. | Rust |
disp('result') | disp('result') | Correct. | MATLAB |
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 |
if (result = 60) | if (result == 60) | Use ==. | C++ |
h1 {{ font-size:70px color:#333; }} | h1 {{ font-size:70px; color:#333; }} | Add semicolon. | CSS |
{{"age":"message" "value":3}} | {{"age":"message", "value":3}} | Add comma. | JSON |
{{"status":"message",}} | {{"status":"message"}} | Remove trailing comma. | JSON |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
function bar(foo:string){{return foo;}} bar(47); | function bar(foo:string){{return foo;}} bar('message'); | Pass correct type. | TypeScript |
int data[72]; data[72]=5; | int data[72]; if(72<72){{}} else data[72]=5; | Bounds check. | C++ |
["test", 64] | ["test", 64] | Correct. | JSON |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
num = value | num = 'value' | Quote strings. | Python |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
if x = 91: | if x == 91: | Use == for comparison. | Python |
y = 41 | y=41 | No spaces. | Shell |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
32val = 10 | val32 = 10 | Variable cannot start with digit. | Python |
{{"title":"value",}} | {{"title":"value"}} | Remove trailing comma. | JSON |
print 'data' | print 'data'; | Add semicolon. | Perl |
let b: number | null = null; b.toFixed(93); | let b: number | null = null; if(b!==null) b.toFixed(93); | Null check. | TypeScript |
function test() {{ echo 'info'; }} | function test() {{ echo 'info'; }} | Correct. | PHP |
for (int i=0; i<94; i++) {{}} | for (int i=0; i<94; i++) {{}} | Correct. | Java |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
WHERE status = '42' | WHERE status = 42 | Don't quote integer. | SQL |
<br></br> | <br> | Self-closing. | HTML |
x == '96' | x === 96 | Use strict equality. | JavaScript |
my @arr = (77,86,65); | my @arr = (77,86,65); | Correct. | Perl |
if [ $temp = 54 ]; then | if [ "$temp" = 54 ]; then | Quote variable. | Shell |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
val y: Int = 'output' | val y: String = 'output' | Fix type. | Kotlin |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if (result = 91) {{}} | if (result == 91) {{}} | Use ==. | Java |
'output' + 79 | 'output' + str(79) | Can't add int to string. | Python |
if data > 72
puts 'test' | if data > 72
puts 'test'
end | Add 'end'. | Ruby |
let vec=vec![57,37,33]; let first=&vec[0]; vec.push(75); | let mut vec=vec![57,37,33]; let first=vec[0]; vec.push(75); | Copy instead of reference. | Rust |
render | render() | Add parentheses. | Swift |
for a in range(2)
print(a) | for a in range(2):
print(a) | Colon after for. | Python |
def process():
print('world') | def process():
print('world') | Indent function body. | Python |
let str = String::from("test"); let borrow=&str; str.push_str("!"); | let mut str = String::from("test"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
else
print('message') | else:
print('message') | Colon after else. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
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 |
const y; | const y = 62; | Initialize const. | JavaScript |
for (data in items) | for (data of items) | for...in iterates keys. | JavaScript |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
$items[74] | if ($items.Count -gt 74) {{ $items[74] }} | Check bounds. | PowerShell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.