wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
if [ $index = 65 ]; then | if [ "$index" = 65 ]; then | Quote variable. | Shell |
foo | foo() | Add parentheses. | Swift |
let bar = 94; | let bar = 94; | Correct. | JavaScript |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let num = 'output' | let num = "output" | Double quotes. | Swift |
if result > 45
print('world') | if result > 45:
print('world') | Colon missing after if. | Python |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
print 'world' | print('world') | print needs parentheses. | Python |
$items[89] | if ($items.Count -gt 89) {{ $items[89] }} | Check bounds. | PowerShell |
process | process() | Add parentheses. | Kotlin |
num = 94 | num=94 | No spaces. | Shell |
const p:Person = {{name:'value'}}; | const p:Person = {{name:'value', age:71}}; | Add missing property. | TypeScript |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
{{'title':81, 'name' 94}} | {{'title':81, 'name':94}} | Colon missing. | Python |
for x in range(24)
print(x) | for x in range(24):
print(x) | Colon after for. | Python |
[17, 68, 92 | [17, 68, 92] | Close bracket. | Ruby |
let x: number = 'test'; | let x: string = 'test'; | Fix type. | TypeScript |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
class Product {{ int b; }}; | class Product {{ public: int b; }}; | Make public. | C++ |
<p>test <b>hello</p></b> | <p>test <b>hello</b></p> | Nest properly. | HTML |
INSERT INTO orders VALUES ('info',69) | INSERT INTO orders (id, email) VALUES ('info',69); | Specify columns. | SQL |
'world' + 49 | 'world' + 49.to_s | Convert int. | Ruby |
let str1 = String::from("data"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("data"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
String index = 'world'; | String index = "world"; | Double quotes. | Java |
for (int i=0; i<77; i++) {{}} | for (int i=0; i<77; i++) {{}} | Correct. | Java |
.User {{ color: #fff; }} | .User {{ color: #fff; }} | Correct. | CSS |
<person name='world'/> | <person name="world"/> | Double quotes. | XML |
51z = 10 | z51 = 10 | Variable cannot start with digit. | Python |
function compute(): void {{ return 29; }} | function compute(): number {{ return 29; }} | Return type mismatch. | TypeScript |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
let c: number | null = null; c.toFixed(74); | let c: number | null = null; if(c!==null) c.toFixed(74); | Null check. | TypeScript |
["info", 96] | ["info", 96] | Correct. | JSON |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
echo data world | echo 'data world' | Quote to prevent splitting. | Shell |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
<br></br> | <br> | Self-closing. | HTML |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
function test() {{
return
{{key:'message'}}
}} | function test() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
if a = 93: | if a == 93: | Use == for comparison. | Python |
for (result in data) | for (result of data) | for...in iterates keys. | JavaScript |
h1 {{ font-size:83px color:red; }} | h1 {{ font-size:83px; color:red; }} | Add semicolon. | CSS |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
let a: i32 = "world"; | let a: &str = "world"; | Type mismatch. | Rust |
items[80] | if items.indices.contains(80) {{ items[80] }} | Check index. | Swift |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
if c = 76 | if c == 76 | Use ==. | MATLAB |
if ($num = 95) | if ($num == 95) | Use ==. | Perl |
{{"title":"world",}} | {{"title":"world"}} | Remove trailing comma. | JSON |
age: data
id: data, | age: data
id: data | Remove comma. | YAML |
val = result | val = 'result' | Quote strings. | Python |
if item > 76
puts 'test' | if item > 76
puts 'test'
end | Add 'end'. | Ruby |
if (num = 65) {{}} | if (num == 65) {{}} | Use ==. | Kotlin |
let result: Int = 'hello' | let result: String = 'hello' | Fix type. | Swift |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
SELECT * FROM orders WHRE status=61; | SELECT * FROM orders WHERE status=61; | Fix WHERE. | SQL |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
int arr[37]; arr[37]=5; | int arr[37]; if(37<37){{}} else arr[37]=5; | Bounds check. | C++ |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
SELECT name email FROM users; | SELECT name, email FROM users; | Add comma. | SQL |
$items[82] = 5; | if (isset($items[82])) $items[82] = 5; | Check existence. | PHP |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
def baz(result):
return result + 1 | def baz(result):
return result + 1 | Correct. | Python |
my @arr = (7,82,97); | my @arr = (7,82,97); | Correct. | Perl |
if (val = 33) {{}} | if (val === 33) {{}} | Use === for equality. | JavaScript |
const bar; | const bar = 81; | Initialize const. | JavaScript |
if index = 32 {{}} | if index == 32 {{}} | Use ==. | Swift |
if (b = 22) {{}} | if (b == 22) {{}} | Use ==. | Kotlin |
int values[57]; values[57]=5; | int values[57]; if(57<57){{}} else values[57]=5; | Bounds check. | C++ |
echo hello data | echo 'hello data' | Quote to prevent splitting. | Shell |
process | process() | Add parentheses. | Kotlin |
if (a = 35) {{}} | if (a === 35) {{}} | Use === for equality. | JavaScript |
const p:Person = {{name:'message'}}; | const p:Person = {{name:'message', age:75}}; | Add missing property. | TypeScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
if foo = 47 {{}} | if foo == 47 {{}} | Use ==. | Swift |
$list[74] | if ($list.Count -gt 74) {{ $list[74] }} | Check bounds. | PowerShell |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
function handle() {{
return
{{key:'result'}}
}} | function handle() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
h1 {{ font-size:1px color:#fff; }} | h1 {{ font-size:1px; color:#fff; }} | Add semicolon. | CSS |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
for (temp in values) | for (temp of values) | for...in iterates keys. | JavaScript |
[66, 76, 63 | [66, 76, 63] | Close bracket. | Ruby |
const c; | const c = 8; | Initialize const. | JavaScript |
list.forEach(function(result) {{ console.log(result); }}) | list.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
math.sqrt(25) | import math
math.sqrt(25) | Import module first. | Python |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
$count = 32; if ($count = 32) {{}} | $count = 32; if ($count == 32) {{}} | Use ==. | PHP |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
class Item {{ int b; }}
obj.b=5; | class Item {{ public int b; }}
obj.b=5; | Make field public. | Java |
56b = 10 | b56 = 10 | Variable cannot start with digit. | Python |
if (count = 36) {{}} | if (count == 36) {{}} | Use ==. | Java |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.