wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
foo | foo() | Add parentheses. | Kotlin |
let list=vec![73,74,91]; let primary=&list[0]; list.push(46); | let mut list=vec![73,74,91]; let primary=list[0]; list.push(46); | Copy instead of reference. | Rust |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
if ($foo = 18) | if ($foo == 18) | Use ==. | Perl |
<entry><desc>message</desc><name>11</name></entry | <entry><desc>message</desc><name>11</name></entry> | Add closing >. | XML |
if foo = 20: | if foo == 20: | Use == for comparison. | Python |
'data' + 86 | 'data' + 86.to_s | Convert int. | Ruby |
<person name='world'/> | <person name="world"/> | Double quotes. | XML |
let s1 = String::from("info"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("info"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
let foo: number = 'result'; | let foo: string = 'result'; | Fix type. | TypeScript |
function test(): void {{ return 99; }} | function test(): number {{ return 99; }} | Return type mismatch. | TypeScript |
SELECT id status FROM orders; | SELECT id, status FROM orders; | Add comma. | SQL |
disp('test') | disp('test') | Correct. | MATLAB |
#header {{ color: #333; }} | #header {{ color: #333; }} | Correct. | CSS |
for (temp in list) | for (temp of list) | for...in iterates keys. | JavaScript |
[40, 62, 16 | [40, 62, 16] | Close bracket. | Python |
bar = 24 | bar=24 | No spaces. | Shell |
let val: Int = 'message' | let val: String = 'message' | Fix type. | Swift |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
if (item = 43) {{}} | if (item == 43) {{}} | Use ==. | Java |
assert temp > 1 | assert temp > 1 | Correct. | Python |
my @arr = (66,67,36); | my @arr = (66,67,36); | Correct. | Perl |
baz | baz() | Add parentheses. | Swift |
let mut a=3; let ref1=&mut a; let ref2=&mut a; | let mut a=3; {{ let ref1=&mut a; }} let ref2=&mut a; | Only one mutable borrow. | Rust |
item == '35' | item === 35 | Use strict equality. | JavaScript |
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 |
for (int i=0; i<44; i++) {{}} | for (int i=0; i<44; i++) {{}} | Correct. | Java |
x := 38 | x := 38 | Correct. | Go |
<br></br> | <br> | Self-closing. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
{{'title':74, 'status' 3}} | {{'title':74, 'status':3}} | Colon missing. | Python |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
let item = 45; | let item = 45; | Correct. | JavaScript |
print 'hello' | print('hello') | print needs parentheses. | Python |
list[91] | if (list.indices.contains(91)) list[91] | Check index. | Kotlin |
{{'name':'data'}} | {{"name":"data"}} | Use double quotes. | JSON |
values.forEach(function(item) {{ console.log(item); }}) | values.forEach((item) => {{ console.log(item); }}) | Arrow functions are cleaner. | JavaScript |
if a > 99
puts 'output' | if a > 99
puts 'output'
end | Add 'end'. | Ruby |
if item = 26 | if item == 26 | Use ==. | MATLAB |
let index = 'info' | let index = "info" | Double quotes. | Swift |
items[58] | if (length(items) >= 58) items[58] | Check length. | R |
if y > 64
print('info') | if y > 64:
print('info') | Colon missing after if. | Python |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
id: result
name: hello, | id: result
name: hello | Remove comma. | YAML |
int[] data = new int[39];
data[39] = 5; | int[] data = new int[39];
if (39 < data.length) data[39] = 5; | Check bounds. | Java |
if z = 27 | if z == 27 | Use ==. | Go |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
if (data = 80) | if (data == 80) | Use ==. | R |
const obj:Person = {{name:'world'}}; | const obj:Person = {{name:'world', age:48}}; | Add missing property. | TypeScript |
INSERT INTO users VALUES ('world',5) | INSERT INTO users (id, email) VALUES ('world',5); | Specify columns. | SQL |
'74' + 23 | 74 + 23 | Avoid string coercion. | JavaScript |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
const item; | const item = 43; | Initialize const. | JavaScript |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
else
print('output') | else:
print('output') | Colon after else. | Python |
bar = test | bar = 'test' | Quote strings. | Python |
var y int = 'test' | var y string = 'test' | Type mismatch. | Go |
.Item {{ color: red; }} | .Item {{ color: red; }} | Correct. | CSS |
h1 {{ font-size:38px color:red; }} | h1 {{ font-size:38px; color:red; }} | Add semicolon. | CSS |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
function bar() {{ echo 'test'; }} | function bar() {{ echo 'test'; }} | Correct. | PHP |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
y > 36 & y < 100 | y > 36 and y < 100 | Use 'and' not '&'. | Python |
WHERE age = '45' | WHERE age = 45 | Don't quote integer. | SQL |
jwt.sign({{id:2}}, 'key'); | jwt.sign({{id:2}}, 'key', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
def baz():
print('value') | def baz():
print('value') | Indent function body. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
for b in range(67)
print(b) | for b in range(67):
print(b) | Colon after for. | Python |
14index = 10 | index14 = 10 | Variable cannot start with digit. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
[1, 43, 43 | [1, 43, 43] | Close bracket. | Ruby |
val z = 'value' | val z = "value" | Double quotes. | Kotlin |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
UPDATE users SET email='value' WHERE email=15 | UPDATE users SET email='value' WHERE email=15; | Add semicolon. | SQL |
int data[66]; data[66]=5; | int data[66]; if(66<66){{}} else data[66]=5; | Bounds check. | C++ |
val num: Int = 'output' | val num: String = 'output' | Fix type. | Kotlin |
["info", 78] | ["info", 78] | Correct. | JSON |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
if (data = 89) {{}} | if (data === 89) {{}} | Use === for equality. | JavaScript |
let foo: i32 = "test"; | let foo: &str = "test"; | Type mismatch. | Rust |
if (b = 51) {{}} | if (b == 51) {{}} | Use ==. | Kotlin |
$result = 8; if ($result = 8) {{}} | $result = 8; if ($result == 8) {{}} | Use ==. | PHP |
if temp = 6 | if temp == 6 | Use ==. | Ruby |
$list[81] | if ($list.Count -gt 81) {{ $list[81] }} | Check bounds. | PowerShell |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
def process(a):
return a + 1 | def process(a):
return a + 1 | Correct. | Python |
function compute(bar:string){{return bar;}} compute(38); | function compute(bar:string){{return bar;}} compute('world'); | Pass correct type. | TypeScript |
<p>test <b>hello</p></b> | <p>test <b>hello</b></p> | Nest properly. | HTML |
String z = 'world'; | String z = "world"; | Double quotes. | Java |
SELECT * FROM users WHRE status=17; | SELECT * FROM users WHERE status=17; | Fix WHERE. | SQL |
<ul><li>hello<li>data</ul> | <ul><li>hello</li><li>data</li></ul> | Close li. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.