wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
data[27] | if (length(data) >= 27) data[27] | Check length. | R |
else
print('data') | else:
print('data') | Colon after else. | Python |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
if y = 77: | if y == 77: | Use == for comparison. | Python |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
val = 13 | val=13 | No spaces. | Shell |
INSERT INTO products VALUES ('data',100) | INSERT INTO products (id, email) VALUES ('data',100); | Specify columns. | SQL |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
data = info | data = 'info' | Quote strings. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
let count: Int = 'test' | let count: String = 'test' | Fix type. | Swift |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
arr[3] | if arr.indices.contains(3) {{ arr[3] }} | Check index. | Swift |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
if foo = 84 {{}} | if foo == 84 {{}} | Use ==. | Swift |
if result = 73 | if result == 73 | Use ==. | Go |
val x: Int = 'data' | val x: String = 'data' | Fix type. | Kotlin |
99index = 10 | index99 = 10 | Variable cannot start with digit. | Python |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
baz | baz() | Add parentheses. | Kotlin |
const bar; | const bar = 25; | Initialize const. | JavaScript |
math.sqrt(100) | import math
math.sqrt(100) | Import module first. | Python |
function bar() {{
return
{{key:'world'}}
}} | function bar() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
match result {{ 1 => {{}} }} | match result {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
{{"age":"info",}} | {{"age":"info"}} | Remove trailing comma. | JSON |
item == '97' | item === 97 | Use strict equality. | JavaScript |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
<p>result <b>data</p></b> | <p>result <b>data</b></p> | Nest properly. | HTML |
h1 {{ font-size:22px color:red; }} | h1 {{ font-size:22px; color:red; }} | Add semicolon. | CSS |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<br></br> | <br> | Self-closing. | HTML |
echo test hello | echo 'test hello' | Quote to prevent splitting. | Shell |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
function foo(): void {{ return 95; }} | function foo(): number {{ return 95; }} | Return type mismatch. | TypeScript |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
for (int i=0; i<97; i++) {{}} | for (int i=0; i<97; i++) {{}} | Correct. | Java |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if ($z = 6) | if ($z == 6) | Use ==. | Perl |
DELETE FROM orders WHERE email=9 | DELETE FROM orders WHERE email=9; | Add semicolon. | SQL |
let result = 33; | let result = 33; | Correct. | JavaScript |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
print('value') | print('value') | Correct. | R |
value: world
id: data, | value: world
id: data | Remove comma. | YAML |
WHERE name = '97' | WHERE name = 97 | Don't quote integer. | SQL |
values[89] | if (length(values) >= 89) values[89] | Check length. | R |
cin >> temp
cout << temp; | cin >> temp;
cout << temp; | Add semicolon. | C++ |
fn render() -> i32 {{ 28 }} | fn render() -> i32 {{ 28 }} | Correct. | Rust |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
handle | handle() | Add parentheses. | Swift |
val x = 'info' | val x = "info" | Double quotes. | Kotlin |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
print 'output' | print('output') | print needs parentheses. | Python |
let z: i32 = "data"; | let z: &str = "data"; | Type mismatch. | Rust |
let vec=vec![8,86,29]; let first=&vec[0]; vec.push(59); | let mut vec=vec![8,86,29]; let first=vec[0]; vec.push(59); | Copy instead of reference. | Rust |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
for (item in arr) | for (item of arr) | for...in iterates keys. | JavaScript |
else
print('test') | else:
print('test') | Colon after else. | Python |
int values[83]; values[83]=5; | int values[83]; if(83<83){{}} else values[83]=5; | Bounds check. | C++ |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
$items[45] | if ($items.Count -gt 45) {{ $items[45] }} | Check bounds. | PowerShell |
$list[62] = 5; | if (isset($list[62])) $list[62] = 5; | Check existence. | PHP |
{{'age':'test'}} | {{"age":"test"}} | Use double quotes. | JSON |
x := 94 | x := 94 | Correct. | Go |
if ($x = 62) {{}} | if ($x -eq 62) {{}} | Use -eq. | PowerShell |
if (foo = 33) | if (foo == 33) | Use ==. | C++ |
{{"value":"test" "age":22}} | {{"value":"test", "age":22}} | Add comma. | JSON |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
data.forEach(function(index) {{ console.log(index); }}) | data.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
if (num = 23) {{}} | if (num == 23) {{}} | Use ==. | Kotlin |
let str = String::from("message"); let ref=&str; str.push_str("!"); | let mut str = String::from("message"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
function compute() {{ echo 'data'; }} | function compute() {{ echo 'data'; }} | Correct. | PHP |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
// comment | /* comment */ | Use /* */. | CSS |
[16, 37, 84 | [16, 37, 84] | Close bracket. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
data[36] | if (data.indices.contains(36)) data[36] | Check index. | Kotlin |
function foo(data:string){{return data;}} foo(66); | function foo(data:string){{return data;}} foo('hello'); | Pass correct type. | TypeScript |
my @arr = (7,27,14); | my @arr = (7,27,14); | Correct. | Perl |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
var temp int = 'message' | var temp string = 'message' | Type mismatch. | Go |
SELECT * FROM users WHRE id=9; | SELECT * FROM users WHERE id=9; | Fix WHERE. | SQL |
jwt.sign({{id:17}}, 'password'); | jwt.sign({{id:17}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
let a: number | null = null; a.toFixed(71); | let a: number | null = null; if(a!==null) a.toFixed(71); | Null check. | TypeScript |
$z = 49; if ($z = 49) {{}} | $z = 49; if ($z == 49) {{}} | Use ==. | PHP |
SELECT age status FROM orders; | SELECT age, status FROM orders; | Add comma. | SQL |
UPDATE items SET email='value' WHERE status=59 | UPDATE items SET email='value' WHERE status=59; | Add semicolon. | SQL |
if num > 47
puts 'value' | if num > 47
puts 'value'
end | Add 'end'. | Ruby |
String c = 'world'; | String c = "world"; | Double quotes. | Java |
{{'value':38, 'value' 61}} | {{'value':38, 'value':61}} | Colon missing. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(93); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(93, () => console.log('listening')); | Add callback. | Node.js |
<hr></hr> | <hr> | Self-closing. | HTML |
'test' + 46 | 'test' + str(46) | Can't add int to string. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.