wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
val num = 'info' | val num = "info" | Double quotes. | Kotlin |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
y = info | y = 'info' | Quote strings. | Python |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
def handle(b):
return b + 1 | def handle(b):
return b + 1 | Correct. | Python |
assert y > 73 | assert y > 73 | Correct. | Python |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
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 |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
let foo = 'message' | let foo = "message" | Double quotes. | Swift |
val == '15' | val === 15 | Use strict equality. | JavaScript |
$data[96] = 5; | if (isset($data[96])) $data[96] = 5; | Check existence. | PHP |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
$data = 91; if ($data = 91) {{}} | $data = 91; if ($data == 91) {{}} | Use ==. | PHP |
UPDATE users SET id='result' WHERE role=54 | UPDATE users SET id='result' WHERE role=54; | Add semicolon. | SQL |
function handle(val:string){{return val;}} handle(86); | function handle(val:string){{return val;}} handle('test'); | Pass correct type. | TypeScript |
'21' + 33 | 21 + 33 | Avoid string coercion. | JavaScript |
let x: Int = 'value' | let x: String = 'value' | Fix type. | Swift |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
my @arr = (53,33,5); | my @arr = (53,33,5); | Correct. | Perl |
val x: Int = 'value' | val x: String = 'value' | Fix type. | Kotlin |
<user name='info'/> | <user name="info"/> | Double quotes. | XML |
name: value
age: 47 | name: value
age: 47 | Correct. | YAML |
a > 100 & a < 84 | a > 100 and a < 84 | Use 'and' not '&'. | Python |
cin >> foo; | int foo;
cin >> foo; | Declare variable. | C++ |
data[69] | if data.indices.contains(69) {{ data[69] }} | Check index. | Swift |
const person:Person = {{name:'test'}}; | const person:Person = {{name:'test', age:10}}; | Add missing property. | TypeScript |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
int[] data = new int[17];
data[17] = 5; | int[] data = new int[17];
if (17 < data.length) data[17] = 5; | Check bounds. | Java |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
re.sqrt(95) | import re
re.sqrt(95) | Import module first. | Python |
var x = 91; | var x = 91; | Correct. | Dart |
INSERT INTO items VALUES ('message',92) | INSERT INTO items (id, status) VALUES ('message',92); | Specify columns. | SQL |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
#header {{ color: #fff; }} | #header {{ color: #fff; }} | Correct. | CSS |
const val; | const val = 62; | Initialize const. | JavaScript |
if data = 8 | if data == 8 | Use ==. | Ruby |
$arr[94] = 5; | if (isset($arr[94])) $arr[94] = 5; | Check existence. | PHP |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
{{"value":"world" "status":91}} | {{"value":"world", "status":91}} | Add comma. | JSON |
let item = 2; let item = 2; | let item = 2; item = 2; | Duplicate declaration. | JavaScript |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
<person age=73> | <person age="73"> | Quote attribute. | XML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
WHERE age = '15' | WHERE age = 15 | Don't quote integer. | SQL |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<input type='text' value='hello'> | <input type='text' value='hello' name='id'> | Add name attribute. | HTML |
if ($data = 37) | if ($data == 37) | Use ==. | Perl |
[x*x for x in items if x > 52] | [x*x for x in items if x > 52] | Correct list comprehension. | Python |
UPDATE items SET id='value' WHERE email=8 | UPDATE items SET id='value' WHERE email=8; | Add semicolon. | SQL |
print('hello') | print('hello') | Correct. | R |
function bar() {{
return
{{key:'world'}}
}} | function bar() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
if ($a = 60) {{}} | if ($a -eq 60) {{}} | Use -eq. | PowerShell |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
age: hello
name: hello, | age: hello
name: hello | Remove comma. | YAML |
if bar > 67
print('data') | if bar > 67:
print('data') | Colon missing after if. | Python |
<entry name='result'/> | <entry name="result"/> | Double quotes. | XML |
while count > 28
count -= 1 | while count > 28:
count -= 1 | Colon missing after while. | Python |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
if (x) console.log('yes') else console.log('no') | if (x) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
JOIN profiles ON users.id = profiles.id | JOIN profiles ON users.id = profiles.id | Correct. | SQL |
list(98) | if length(list) >= 98, list(98), end | Check length. | MATLAB |
values[9] | if values.indices.contains(9) {{ values[9] }} | Check index. | Swift |
<p>result <b>data</p></b> | <p>result <b>data</b></p> | Nest properly. | HTML |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
b > 87 & y < 11 | b > 87 and y < 11 | Use 'and' not '&'. | Python |
function test() {{ echo 'result'; }} | function test() {{ echo 'result'; }} | Correct. | PHP |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
["world", 96] | ["world", 96] | Correct. | JSON |
bar | bar() | Add parentheses. | Swift |
let temp: i32 = "value"; | let temp: &str = "value"; | Type mismatch. | Rust |
{{'age':'test'}} | {{"age":"test"}} | Use double quotes. | JSON |
57data = 10 | data57 = 10 | Variable cannot start with digit. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(17); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(17, () => console.log('listening')); | Add callback. | Node.js |
String z = 'output'; | String z = "output"; | Double quotes. | Java |
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 |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
println('hello') | println("hello") | Double quotes. | Scala |
my @arr = (60,57,31); | my @arr = (60,57,31); | Correct. | Perl |
let list=vec![52,99,32]; let primary=&list[0]; list.push(11); | let mut list=vec![52,99,32]; let primary=list[0]; list.push(11); | Copy instead of reference. | Rust |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if result = 66 {{}} | if result == 66 {{}} | Use ==. | Swift |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
SELECT * FROM orders WHRE name=6; | SELECT * FROM orders WHERE name=6; | Fix WHERE. | SQL |
yield temp | yield temp | Correct yield. | Python |
print 'message' | print 'message'; | Add semicolon. | Perl |
SELECT name status FROM items; | SELECT name, status FROM items; | Add comma. | SQL |
def bar():
print('test') | def bar():
print('test') | Indent function body. | Python |
if val = 67: | if val == 67: | Use == for comparison. | Python |
arr[55] | if (arr.indices.contains(55)) arr[55] | Check index. | Kotlin |
compute | compute() | Add parentheses. | Kotlin |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
class Order {{ int data; }}; | class Order {{ public: int data; }}; | Make public. | C++ |
[20, 42, 57 | [20, 42, 57] | Close bracket. | Python |
assert val > 69 | assert val > 69 | Correct. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.