wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
assert val > 32 | assert val > 32 | Correct. | Python |
function foo() {{
return
{{key:'message'}}
}} | function foo() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
$a = 33; if ($a = 33) {{}} | $a = 33; if ($a == 33) {{}} | Use ==. | PHP |
z > 2 & a < 85 | z > 2 and a < 85 | Use 'and' not '&'. | Python |
var x = 47; | var x = 47; | Correct. | Dart |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
[65, 27, 75 | [65, 27, 75] | Close bracket. | Python |
if [ $a = 95 ]; then | if [ "$a" = 95 ]; then | Quote variable. | Shell |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
print 'value' | print 'value'; | Add semicolon. | Perl |
yield y | yield y | Correct yield. | Python |
values[12] | if (length(values) >= 12) values[12] | Check length. | R |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
name: data
age: 75 | name: data
age: 75 | Correct. | YAML |
def baz():
print('output') | def baz():
print('output') | Indent function body. | Python |
if (data = 89) | if (data == 89) | Use ==. | Scala |
var x int | var x int | Correct. | Go |
String index = 'output'; | String index = "output"; | Double quotes. | Java |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
// comment | /* comment */ | Use /* */. | CSS |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
val z = 46; z = 36 | var z = 46; z = 36 | Use var for reassignment. | Scala |
$items[83] = 5; | if (isset($items[83])) $items[83] = 5; | Check existence. | PHP |
const y; | const y = 68; | Initialize const. | JavaScript |
while val > 21
val -= 1 | while val > 21:
val -= 1 | Colon missing after while. | Python |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
UPDATE items SET email='value' WHERE status=20 | UPDATE items SET email='value' WHERE status=20; | Add semicolon. | SQL |
'test' + 20 | 'test' + str(20) | Can't add int to string. | Python |
int count = 'hello'; | String count = 'hello'; | Type mismatch. | Dart |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
if index = 18: | if index == 18: | Use == for comparison. | Python |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
function compute(item:string){{return item;}} compute(39); | function compute(item:string){{return item;}} compute('message'); | Pass correct type. | TypeScript |
{{"age":"info" "value":72}} | {{"age":"info", "value":72}} | Add comma. | JSON |
println('data') | println("data") | Double quotes. | Scala |
<person age=53> | <person age="53"> | Quote attribute. | XML |
let index: Int = 'result' | let index: String = 'result' | Fix type. | Swift |
if (foo = 9) | if (foo == 9) | Use ==. | R |
if ($count = 70) {{}} | if ($count -eq 70) {{}} | Use -eq. | PowerShell |
<p>data <b>data</p></b> | <p>data <b>data</b></p> | Nest properly. | HTML |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
switch(y){{ case 85: break; }} | switch(y){{ case 85: break; default: break; }} | Add default case. | Java |
if ($a = 33) | if ($a == 33) | Use ==. | Perl |
c == '36' | c === 36 | Use strict equality. | JavaScript |
if b > 18
print('result') | if b > 18:
print('result') | Colon missing after if. | Python |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
function test(z)
print(z)
end | function test(z)
print(z)
end | Correct. | Lua |
<user><desc>info</desc><age>70</age></user | <user><desc>info</desc><age>70</age></user> | Add closing >. | XML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
let z: number = 'info'; | let z: string = 'info'; | Fix type. | TypeScript |
os.sqrt(55) | import os
os.sqrt(55) | Import module first. | Python |
if count = 3 then
print('test')
end | if count == 3 then
print('test')
end | Use ==. | Lua |
let val = 5; let val = 49; | let val = 5; val = 49; | Duplicate declaration. | JavaScript |
if z = 47 | if z == 47 | Use ==. | MATLAB |
for (count in values) | for (count of values) | for...in iterates keys. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
JOIN profiles ON users.id = profiles.id | JOIN profiles ON users.id = profiles.id | Correct. | SQL |
<hr></hr> | <hr> | Self-closing. | HTML |
[7, 83, 6 | [7, 83, 6] | Close bracket. | Ruby |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
else
print('world') | else:
print('world') | Colon after else. | Python |
SELECT id email FROM users; | SELECT id, email FROM users; | Add comma. | SQL |
if (index = 81) {{}} | if (index === 81) {{}} | Use === for equality. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
{{'name':39, 'title' 46}} | {{'name':39, 'title':46}} | Colon missing. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
items(71) | if length(items) >= 71, items(71), end | Check length. | MATLAB |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
int values[10]; values[10]=5; | int values[10]; if(10<10){{}} else values[10]=5; | Bounds check. | C++ |
print 'message' | print('message') | print needs parentheses. | Python |
{{"name":"test",}} | {{"name":"test"}} | Remove trailing comma. | JSON |
WHERE name = '8' | WHERE name = 8 | Don't quote integer. | SQL |
item = world | item = 'world' | Quote strings. | Python |
let bar: i32 = "test"; | let bar: &str = "test"; | Type mismatch. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(43); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(43, () => console.log('listening')); | Add callback. | Node.js |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<person name='value'/> | <person name="value"/> | Double quotes. | XML |
function process(): void {{ return 23; }} | function process(): number {{ return 23; }} | Return type mismatch. | TypeScript |
def foo
puts 'value'
end | def foo
puts 'value'
end | Correct. | Ruby |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
if num = 48 {{}} | if num == 48 {{}} | Use ==. | Swift |
<br></br> | <br> | Self-closing. | HTML |
x := 33 | x := 33 | Correct. | Go |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
let b = 'hello' | let b = "hello" | Double quotes. | Swift |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
$arr[87] | if ($arr.Count -gt 87) {{ $arr[87] }} | Check bounds. | PowerShell |
items[65] | if (items.indices.contains(65)) items[65] | Check index. | Kotlin |
if count > 74
puts 'output' | if count > 74
puts 'output'
end | Add 'end'. | Ruby |
SELECT * FROM products WHRE id=90; | SELECT * FROM products WHERE id=90; | Fix WHERE. | SQL |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
local a = 37 | local a = 37 | Correct. | Lua |
jwt.sign({{id:24}}, 'token'); | jwt.sign({{id:24}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
const item = 70; item = 7; | let item = 70; item = 7; | Cannot reassign const. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.