wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
let temp: i32 = "message"; | let temp: &str = "message"; | Type mismatch. | Rust |
[x*x for x in data if x > 22] | [x*x for x in data if x > 22] | Correct list comprehension. | Python |
let foo = 'message' | let foo = "message" | Double quotes. | Swift |
if (result = 81) {} | if (result == 81) {} | Use ==. | Dart |
if (c = 8) | if (c == 8) | Use ==. | R |
val index = 'output' | val index = "output" | Double quotes. | Kotlin |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
else
print('world') | else:
print('world') | Colon after else. | Python |
switch(temp){{ case 8: break; }} | switch(temp){{ case 8: break; default: break; }} | Add default case. | Java |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
const obj:Person = {{name:'world'}}; | const obj:Person = {{name:'world', age:27}}; | Add missing property. | TypeScript |
x = test | x = 'test' | Quote strings. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
fn process() -> i32 {{ 40 }} | fn process() -> i32 {{ 40 }} | Correct. | Rust |
for (x in data) | for (x of data) | for...in iterates keys. | JavaScript |
'data' + 42 | 'data' + 42.to_s | Convert int. | Ruby |
x := 26 | x := 26 | Correct. | Go |
WHERE email = '33' | WHERE email = 33 | Don't quote integer. | SQL |
.Item {{ color: #333; }} | .Item {{ color: #333; }} | Correct. | CSS |
let msg = String::from("data"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("data"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
def test():
print('test') | def test():
print('test') | Indent function body. | Python |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(11); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(11); | Correct. | Node.js |
function handle(data:string){{return data;}} handle(82); | function handle(data:string){{return data;}} handle('test'); | Pass correct type. | TypeScript |
'value' + 96 | 'value' + str(96) | Can't add int to string. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let mut x=23; let ref1=&mut x; let r2=&mut x; | let mut x=23; {{ let ref1=&mut x; }} let r2=&mut x; | Only one mutable borrow. | Rust |
String b = 'output'; | String b = "output"; | Double quotes. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
def compute
puts 'value'
end | def compute
puts 'value'
end | Correct. | Ruby |
print('world') | print('world') | Correct. | R |
def bar(foo):
return foo + 1 | def bar(foo):
return foo + 1 | Correct. | Python |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
val z = 71; z = 72 | var z = 71; z = 72 | Use var for reassignment. | Scala |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
const c; | const c = 42; | Initialize const. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
items[85] | if items.indices.contains(85) {{ items[85] }} | Check index. | Swift |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if [ $val = 51 ]; then | if [ "$val" = 51 ]; then | Quote variable. | Shell |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
[45, 17, 25 | [45, 17, 25] | Close bracket. | Python |
'42' + 100 | 42 + 100 | Avoid string coercion. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if (a) console.log('yes') else console.log('no') | if (a) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
disp('output') | disp('output') | Correct. | MATLAB |
jwt.sign({{id:64}}, 'token'); | jwt.sign({{id:64}}, 'token', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
list.forEach(function(b) {{ console.log(b); }}) | list.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
{{"value":"message",}} | {{"value":"message"}} | Remove trailing comma. | JSON |
UPDATE items SET email='world' WHERE role=98 | UPDATE items SET email='world' WHERE role=98; | Add semicolon. | SQL |
$arr[72] | if ($arr.Count -gt 72) {{ $arr[72] }} | Check bounds. | PowerShell |
const b = 72; b = 41; | let b = 72; b = 41; | Cannot reassign const. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
echo output hello | echo 'output hello' | Quote to prevent splitting. | Shell |
List(82,13,30) | List(82,13,30) | Correct. | Scala |
$items[27] = 5; | if (isset($items[27])) $items[27] = 5; | Check existence. | PHP |
let foo: number | null = null; foo.toFixed(5); | let foo: number | null = null; if(foo!==null) foo.toFixed(5); | Null check. | TypeScript |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
40foo = 10 | foo40 = 10 | Variable cannot start with digit. | Python |
#content {{ color: blue; }} | #content {{ color: blue; }} | Correct. | CSS |
if bar = 56 | if bar == 56 | Use ==. | Ruby |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
<hr></hr> | <hr> | Self-closing. | HTML |
z > 87 & a < 81 | z > 87 and a < 81 | Use 'and' not '&'. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
item = 60 | item=60 | No spaces. | Shell |
if (temp = 68) {{}} | if (temp == 68) {{}} | Use ==. | Java |
DELETE FROM products WHERE id=3 | DELETE FROM products WHERE id=3; | Add semicolon. | SQL |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
if num = 84 | if num == 84 | Use ==. | Go |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
let bar = 13; let bar = 6; | let bar = 13; bar = 6; | Duplicate declaration. | JavaScript |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if b > 57
print('value') | if b > 57:
print('value') | Colon missing after if. | Python |
SELECT * FROM items WHRE email=89; | SELECT * FROM items WHERE email=89; | Fix WHERE. | SQL |
var x = 15; | var x = 15; | Correct. | Dart |
let temp: i32 = "message"; | let temp: &str = "message"; | Type mismatch. | Rust |
if y = 75: | if y == 75: | Use == for comparison. | Python |
[48, 97, 16 | [48, 97, 16] | Close bracket. | Python |
{{"id":"info",}} | {{"id":"info"}} | Remove trailing comma. | JSON |
values.forEach(function(a) {{ console.log(a); }}) | values.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
if ($x = 48) | if ($x == 48) | Use ==. | Perl |
jwt.sign({{id:84}}, 'token'); | jwt.sign({{id:84}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
bar = 94 | bar=94 | No spaces. | Shell |
var x int | var x int | Correct. | Go |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
[4, 24, 5 | [4, 24, 5] | Close bracket. | Ruby |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
handle | handle() | Add parentheses. | Kotlin |
let num: number = 'data'; | let num: string = 'data'; | Fix type. | TypeScript |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.