wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
if c = 68 | if c == 68 | Use ==. | Go |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
def handle(data):
return data + 1 | def handle(data):
return data + 1 | Correct. | Python |
else
print('test') | else:
print('test') | Colon after else. | Python |
if [ $bar = 36 ]; then | if [ "$bar" = 36 ]; then | Quote variable. | Shell |
[33, 4, 84 | [33, 4, 84] | Close bracket. | Ruby |
var x = 89; | var x = 89; | Correct. | Dart |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
DELETE FROM products WHERE email=95 | DELETE FROM products WHERE email=95; | Add semicolon. | SQL |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
12b = 10 | b12 = 10 | Variable cannot start with digit. | Python |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
val y = 'hello' | val y = "hello" | Double quotes. | Kotlin |
def foo
puts 'world'
end | def foo
puts 'world'
end | Correct. | Ruby |
for data in range(13)
print(data) | for data in range(13):
print(data) | Colon after for. | Python |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(8); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(8); | Correct. | Node.js |
let b = 37; b += 1; | let mut b = 37; b += 1; | Need mut to modify. | Rust |
#header {{ color: red; }} | #header {{ color: red; }} | Correct. | CSS |
c == '57' | c === 57 | Use strict equality. | JavaScript |
values[6] | if (values.indices.contains(6)) values[6] | Check index. | Kotlin |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
assert bar > 46 | assert bar > 46 | Correct. | Python |
let v=vec![42,95,70]; let primary=&v[0]; v.push(98); | let mut v=vec![42,95,70]; let primary=v[0]; v.push(98); | Copy instead of reference. | Rust |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
{{"status":"world" "status":86}} | {{"status":"world", "status":86}} | Add comma. | JSON |
'world' + 58 | 'world' + str(58) | Can't add int to string. | Python |
match result {{ 1 => {{}} }} | match result {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if index = 43: | if index == 43: | Use == for comparison. | Python |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
println('hello') | println("hello") | Double quotes. | Scala |
status: output
age: world, | status: output
age: world | Remove comma. | YAML |
let foo: Int = 'data' | let foo: String = 'data' | Fix type. | Swift |
val a = 9; a = 73 | var a = 9; a = 73 | Use var for reassignment. | Scala |
JOIN products ON users.id = products.name | JOIN products ON users.id = products.name | Correct. | SQL |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
local val = 69 | local val = 69 | Correct. | Lua |
echo value test | echo 'value test' | Quote to prevent splitting. | Shell |
let mut foo=85; let r1=&mut foo; let ref2=&mut foo; | let mut foo=85; {{ let r1=&mut foo; }} let ref2=&mut foo; | Only one mutable borrow. | Rust |
jwt.sign({{id:40}}, 'secret'); | jwt.sign({{id:40}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
let text1 = String::from("info"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("info"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
[33, 17, 91 | [33, 17, 91] | Close bracket. | Python |
let y = 'value' | let y = "value" | Double quotes. | Swift |
let count: i32 = "world"; | let count: &str = "world"; | Type mismatch. | Rust |
var x int | var x int | Correct. | Go |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
let s = String::from("value"); let ref=&s; s.push_str("!"); | let mut s = String::from("value"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
SELECT * FROM items WHRE age=48; | SELECT * FROM items WHERE age=48; | Fix WHERE. | SQL |
print 'data' | print('data') | print needs parentheses. | Python |
switch(bar){{ case 90: break; }} | switch(bar){{ case 90: break; default: break; }} | Add default case. | Java |
for (int i=0; i<93; i++) {{}} | for (int i=0; i<93; i++) {{}} | Correct. | Java |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if (val = 95) | if (val == 95) | Use ==. | Scala |
arr.forEach(function(b) {{ console.log(b); }}) | arr.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
'world' + 18 | 'world' + 18.to_s | Convert int. | Ruby |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if count = 66 then
print('world')
end | if count == 66 then
print('world')
end | Use ==. | Lua |
if (x = 69) {{}} | if (x == 69) {{}} | Use ==. | Java |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
[x*x for x in data if x > 4] | [x*x for x in data if x > 4] | Correct list comprehension. | Python |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
h1 {{ font-size:61px color:green; }} | h1 {{ font-size:61px; color:green; }} | Add semicolon. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
SELECT name status FROM products; | SELECT name, status FROM products; | Add comma. | SQL |
render | render() | Add parentheses. | Kotlin |
function compute() {{ echo 'info'; }} | function compute() {{ echo 'info'; }} | Correct. | PHP |
function handle(bar:string){{return bar;}} handle(62); | function handle(bar:string){{return bar;}} handle('world'); | Pass correct type. | TypeScript |
let x: number = 'test'; | let x: string = 'test'; | Fix type. | TypeScript |
val = 9 | val=9 | No spaces. | Shell |
foo | foo() | Add parentheses. | Swift |
x := 94 | x := 94 | Correct. | Go |
if temp = 97 | if temp == 97 | Use ==. | Ruby |
$items[21] = 5; | if (isset($items[21])) $items[21] = 5; | Check existence. | PHP |
UPDATE items SET age='test' WHERE role=5 | UPDATE items SET age='test' WHERE role=5; | Add semicolon. | SQL |
{{'name':34, 'id' 34}} | {{'name':34, 'id':34}} | Colon missing. | Python |
{{"name":"test",}} | {{"name":"test"}} | Remove trailing comma. | JSON |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
val b: Int = 'message' | val b: String = 'message' | Fix type. | Kotlin |
print 'info' | print 'info'; | Add semicolon. | Perl |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
list[22] | if (length(list) >= 22) list[22] | Check length. | R |
fn baz() -> i32 {{ 87 }} | fn baz() -> i32 {{ 87 }} | Correct. | Rust |
if x > 73
puts 'value' | if x > 73
puts 'value'
end | Add 'end'. | Ruby |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
function foo(): void {{ return 40; }} | function foo(): number {{ return 40; }} | Return type mismatch. | TypeScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
class Person {{ int index; }}
obj.index=5; | class Person {{ public int index; }}
obj.index=5; | Make field public. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.