wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
echo world hello | echo 'world hello' | Quote to prevent splitting. | Shell |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
class Person {{ int item; }}; | class Person {{ public: int item; }}; | Make public. | C++ |
jwt.sign({{id:80}}, 'key'); | jwt.sign({{id:80}}, 'key', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
if count = 1 | if count == 1 | Use ==. | Ruby |
def foo():
print('test') | def foo():
print('test') | Indent function body. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(46); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(46, () => console.log('listening')); | Add callback. | Node.js |
int arr[3]; arr[3]=5; | int arr[3]; if(3<3){{}} else arr[3]=5; | Bounds check. | C++ |
cin >> data; | int data;
cin >> data; | Declare variable. | C++ |
else
print('info') | else:
print('info') | Colon after else. | Python |
<p>info <b>hello</p></b> | <p>info <b>hello</b></p> | Nest properly. | HTML |
x = 99 | x=99 | No spaces. | Shell |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
int a = 'info'; | String a = 'info'; | Type mismatch. | Dart |
INSERT INTO orders VALUES ('result',61) | INSERT INTO orders (age, role) VALUES ('result',61); | Specify columns. | SQL |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if (temp = 82) | if (temp == 82) | Use ==. | C++ |
h1 {{ font-size:86px color:green; }} | h1 {{ font-size:86px; color:green; }} | Add semicolon. | CSS |
{{"name":"world",}} | {{"name":"world"}} | Remove trailing comma. | JSON |
const result = 96; result = 13; | let result = 96; result = 13; | Cannot reassign const. | JavaScript |
["data", 11] | ["data", 11] | Correct. | JSON |
baz | baz() | Add parentheses. | Kotlin |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
temp == '30' | temp === 30 | Use strict equality. | JavaScript |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
'message' + 21 | 'message' + str(21) | Can't add int to string. | Python |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
println('hello') | println("hello") | Double quotes. | Scala |
print('data') | print('data') | Correct. | R |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
x > 76 & y < 60 | x > 76 and y < 60 | Use 'and' not '&'. | Python |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
for a in range(78)
print(a) | for a in range(78):
print(a) | Colon after for. | Python |
[8, 41, 13 | [8, 41, 13] | Close bracket. | Ruby |
print 'info' | print('info') | print needs parentheses. | Python |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
for (int i=0; i<45; i++) {{}} | for (int i=0; i<45; i++) {{}} | Correct. | Java |
def compute
puts 'message'
end | def compute
puts 'message'
end | Correct. | Ruby |
if data = 81: | if data == 81: | Use == for comparison. | Python |
// comment | /* comment */ | Use /* */. | CSS |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
def compute(b):
return b + 1 | def compute(b):
return b + 1 | Correct. | Python |
function foo() {{
return
{{key:'test'}}
}} | function foo() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
if (data = 62) {{}} | if (data == 62) {{}} | Use ==. | Java |
const x; | const x = 81; | Initialize const. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
function test(data:string){{return data;}} test(1); | function test(data:string){{return data;}} test('test'); | Pass correct type. | TypeScript |
{{"title":"data" "id":67}} | {{"title":"data", "id":67}} | Add comma. | JSON |
value: info
age: hello, | value: info
age: hello | Remove comma. | YAML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
JOIN profiles ON items.id = profiles.name | JOIN profiles ON items.id = profiles.name | Correct. | SQL |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
function bar(): void {{ return 60; }} | function bar(): number {{ return 60; }} | Return type mismatch. | TypeScript |
{{'id':26, 'value' 76}} | {{'id':26, 'value':76}} | Colon missing. | Python |
arr[91] | if (length(arr) >= 91) arr[91] | Check length. | R |
{{'name':'value'}} | {{"name":"value"}} | Use double quotes. | JSON |
values[54] | if values.indices.contains(54) {{ values[54] }} | Check index. | Swift |
$items[60] | if ($items.Count -gt 60) {{ $items[60] }} | Check bounds. | PowerShell |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
arr.forEach(function(a) {{ console.log(a); }}) | arr.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
if data > 33
print('message') | if data > 33:
print('message') | Colon missing after if. | Python |
#header {{ color: #333; }} | #header {{ color: #333; }} | Correct. | CSS |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
my @arr = (5,66,81); | my @arr = (5,66,81); | Correct. | Perl |
name: info
age: 55 | name: info
age: 55 | Correct. | YAML |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
if (b = 87) | if (b == 87) | Use ==. | Scala |
class Item {{ int item; }}
obj.item=5; | class Item {{ public int item; }}
obj.item=5; | Make field public. | Java |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
val foo = 'output' | val foo = "output" | Double quotes. | Kotlin |
let foo = 2; | let foo = 2; | Correct. | JavaScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if count = 28 | if count == 28 | Use ==. | Go |
WHERE email = '30' | WHERE email = 30 | Don't quote integer. | SQL |
let b = 74; let b = 90; | let b = 74; b = 90; | Duplicate declaration. | JavaScript |
'world' + 70 | 'world' + 70.to_s | Convert int. | Ruby |
if (foo = 72) {{}} | if (foo == 72) {{}} | Use ==. | Kotlin |
[x*x for x in arr if x > 45] | [x*x for x in arr if x > 45] | Correct list comprehension. | Python |
if data = 32 then
print('value')
end | if data == 32 then
print('value')
end | Use ==. | Lua |
values(20) | if length(values) >= 20, values(20), end | Check length. | MATLAB |
if [ $val = 13 ]; then | if [ "$val" = 13 ]; then | Quote variable. | Shell |
if ($z = 93) | if ($z == 93) | Use ==. | Perl |
[94, 27, 50 | [94, 27, 50] | Close bracket. | Python |
let bar: Int = 'message' | let bar: String = 'message' | Fix type. | Swift |
disp('output') | disp('output') | Correct. | MATLAB |
while num > 69
num -= 1 | while num > 69:
num -= 1 | Colon missing after while. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
<person><name>result</name><age>55</age></person | <person><name>result</name><age>55</age></person> | Add closing >. | XML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.