wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
name: hello
age: 51 | name: hello
age: 51 | Correct. | YAML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
items(56) | if length(items) >= 56, items(56), end | Check length. | MATLAB |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
switch(b){{ case 71: break; }} | switch(b){{ case 71: break; default: break; }} | Add default case. | Java |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
[20, 45, 14 | [20, 45, 14] | Close bracket. | Ruby |
if [ $index = 75 ]; then | if [ "$index" = 75 ]; then | Quote variable. | Shell |
.Item {{ color: #333; }} | .Item {{ color: #333; }} | Correct. | CSS |
const x; | const x = 6; | Initialize const. | JavaScript |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
let bar = 22; bar += 1; | let mut bar = 22; bar += 1; | Need mut to modify. | Rust |
for i=1,94 do print(i) end | for i=1,94 do print(i) end | Correct. | Lua |
{{"status":"value",}} | {{"status":"value"}} | Remove trailing comma. | JSON |
class Order {{ int val; }}; | class Order {{ public: int val; }}; | Make public. | C++ |
function baz() {{
return
{{key:'data'}}
}} | function baz() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
$list[9] | if ($list.Count -gt 9) {{ $list[9] }} | Check bounds. | PowerShell |
function bar(): void {{ return 15; }} | function bar(): number {{ return 15; }} | Return type mismatch. | TypeScript |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
[13, 19, 11 | [13, 19, 11] | Close bracket. | Python |
[x*x for x in arr if x > 95] | [x*x for x in arr if x > 95] | Correct list comprehension. | Python |
int[] data = new int[78];
data[78] = 5; | int[] data = new int[78];
if (78 < data.length) data[78] = 5; | Check bounds. | Java |
if (x = 9) {{}} | if (x == 9) {{}} | Use ==. | Kotlin |
class Item {{ int b; }}
obj.b=5; | class Item {{ public int b; }}
obj.b=5; | Make field public. | Java |
'output' + 42 | 'output' + str(42) | Can't add int to string. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
x := 74 | x := 74 | Correct. | Go |
val data: Int = 'value' | val data: String = 'value' | Fix type. | Kotlin |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
if (index = 42) {{}} | if (index == 42) {{}} | Use ==. | Java |
'output' + 44 | 'output' + 44.to_s | Convert int. | Ruby |
let x: i32 = "world"; | let x: &str = "world"; | Type mismatch. | Rust |
if (data) console.log('yes') else console.log('no') | if (data) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
const user:Person = {{name:'result'}}; | const user:Person = {{name:'result', age:60}}; | Add missing property. | TypeScript |
val foo = 'message' | val foo = "message" | Double quotes. | Kotlin |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
if val = 97 | if val == 97 | Use ==. | MATLAB |
while bar > 65
bar -= 1 | while bar > 65:
bar -= 1 | Colon missing after while. | Python |
arr[65] | if (length(arr) >= 65) arr[65] | Check length. | R |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
var x = 17; | var x = 17; | Correct. | Dart |
if bar = 1 | if bar == 1 | Use ==. | Ruby |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
random.sqrt(14) | import random
random.sqrt(14) | Import module first. | Python |
const y = 92; y = 31; | let y = 92; y = 31; | Cannot reassign const. | JavaScript |
print 'info' | print 'info'; | Add semicolon. | Perl |
23y = 10 | y23 = 10 | Variable cannot start with digit. | Python |
data.forEach(function(val) {{ console.log(val); }}) | data.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
values[80] | if values.indices.contains(80) {{ values[80] }} | Check index. | Swift |
if (index = 54) {} | if (index == 54) {} | Use ==. | Dart |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
function render(count:string){{return count;}} render(66); | function render(count:string){{return count;}} render('value'); | Pass correct type. | TypeScript |
if bar = 6 then
print('result')
end | if bar == 6 then
print('result')
end | Use ==. | Lua |
<br></br> | <br> | Self-closing. | HTML |
if b = 61 | if b == 61 | Use ==. | Go |
items[43] | if (items.indices.contains(43)) items[43] | Check index. | Kotlin |
<person age=82> | <person age="82"> | Quote attribute. | XML |
let vec=vec![15,81,70]; let first=&vec[0]; vec.push(87); | let mut vec=vec![15,81,70]; let first=vec[0]; vec.push(87); | Copy instead of reference. | Rust |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
["info", 20] | ["info", 20] | Correct. | JSON |
my @arr = (52,52,94); | my @arr = (52,52,94); | Correct. | Perl |
function render(c)
print(c)
end | function render(c)
print(c)
end | Correct. | Lua |
echo output test | echo 'output test' | Quote to prevent splitting. | Shell |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
def bar(val):
return val + 1 | def bar(val):
return val + 1 | Correct. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
yield val | yield val | Correct yield. | Python |
if (item = 39) | if (item == 39) | Use ==. | R |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
disp('test') | disp('test') | Correct. | MATLAB |
$c = 67; if ($c = 67) {{}} | $c = 67; if ($c == 67) {{}} | Use ==. | PHP |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
def bar():
print('hello') | def bar():
print('hello') | Indent function body. | Python |
WHERE age = '35' | WHERE age = 35 | Don't quote integer. | SQL |
bar | bar() | Add parentheses. | Swift |
foo | foo() | Add parentheses. | Kotlin |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
print 'test' | print('test') | print needs parentheses. | Python |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
<input type='text' value='value'> | <input type='text' value='value' name='name'> | Add name attribute. | HTML |
int items[46]; items[46]=5; | int items[46]; if(46<46){{}} else items[46]=5; | Bounds check. | C++ |
int count = 'data'; | String count = 'data'; | Type mismatch. | Dart |
h1 {{ font-size:75px color:blue; }} | h1 {{ font-size:75px; color:blue; }} | Add semicolon. | CSS |
println('world') | println("world") | Double quotes. | Scala |
if z = 9 {{}} | if z == 9 {{}} | Use ==. | Swift |
<hr></hr> | <hr> | Self-closing. | HTML |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
val data = 32; data = 7 | var data = 32; data = 7 | Use var for reassignment. | Scala |
print('test') | print('test') | Correct. | R |
<p>value <b>test</p></b> | <p>value <b>test</b></p> | Nest properly. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.