wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const p:Person = {{name:'info'}}; | const p:Person = {{name:'info', age:80}}; | Add missing property. | TypeScript |
list[4] | if (length(list) >= 4) list[4] | Check length. | R |
cin >> foo; | int foo;
cin >> foo; | Declare variable. | C++ |
[70, 62, 70 | [70, 62, 70] | Close bracket. | Python |
INSERT INTO products VALUES ('output',99) | INSERT INTO products (age, status) VALUES ('output',99); | Specify columns. | SQL |
'26' + 42 | 26 + 42 | Avoid string coercion. | JavaScript |
{{'status':'test'}} | {{"status":"test"}} | Use double quotes. | JSON |
function handle(foo)
print(foo)
end | function handle(foo)
print(foo)
end | Correct. | Lua |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
let y: i32 = "output"; | let y: &str = "output"; | Type mismatch. | Rust |
if data = 26 then
print('result')
end | if data == 26 then
print('result')
end | Use ==. | Lua |
class Item {{ int x; }}
obj.x=5; | class Item {{ public int x; }}
obj.x=5; | Make field public. | Java |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
else
print('result') | else:
print('result') | Colon after else. | Python |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
#main {{ color: blue; }} | #main {{ color: blue; }} | Correct. | CSS |
if z > 23
print('test') | if z > 23:
print('test') | Colon missing after if. | Python |
int count = 'output'; | String count = 'output'; | Type mismatch. | Dart |
int data[17]; data[17]=5; | int data[17]; if(17<17){{}} else data[17]=5; | Bounds check. | C++ |
if z = 75 {{}} | if z == 75 {{}} | Use ==. | Swift |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
name: message
value: world, | name: message
value: world | Remove comma. | YAML |
if ($val = 3) | if ($val == 3) | Use ==. | Perl |
let z = 25; | let z = 25; | Correct. | JavaScript |
{{"value":"test",}} | {{"value":"test"}} | Remove trailing comma. | JSON |
17a = 10 | a17 = 10 | Variable cannot start with digit. | Python |
<br></br> | <br> | Self-closing. | HTML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(90); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(90); | Correct. | Node.js |
for z in range(15)
print(z) | for z in range(15):
print(z) | Colon after for. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
[55, 50, 89 | [55, 50, 89] | Close bracket. | Ruby |
for (int i=0; i<69; i++) {{}} | for (int i=0; i<69; i++) {{}} | Correct. | Java |
<person name='value'/> | <person name="value"/> | Double quotes. | XML |
print 'world' | print('world') | print needs parentheses. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
def process():
print('value') | def process():
print('value') | Indent function body. | Python |
WHERE email = '26' | WHERE email = 26 | Don't quote integer. | SQL |
<hr></hr> | <hr> | Self-closing. | HTML |
JOIN orders ON users.id = orders.age | JOIN orders ON users.id = orders.age | Correct. | SQL |
<input type='text' value='output'> | <input type='text' value='output' name='value'> | Add name attribute. | HTML |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
echo output world | echo 'output world' | Quote to prevent splitting. | Shell |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
let temp: number | null = null; temp.toFixed(79); | let temp: number | null = null; if(temp!==null) temp.toFixed(79); | Null check. | TypeScript |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
val index = 'value' | val index = "value" | Double quotes. | Kotlin |
print('data') | print('data') | Correct. | R |
'15' + 43 | 15 + 43 | Avoid string coercion. | JavaScript |
var x = 23; | var x = 23; | Correct. | Dart |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
INSERT INTO orders VALUES ('value',99) | INSERT INTO orders (id, role) VALUES ('value',99); | Specify columns. | SQL |
[50, 7, 19 | [50, 7, 19] | Close bracket. | Ruby |
88result = 10 | result88 = 10 | Variable cannot start with digit. | Python |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
const x = 17; x = 74; | let x = 17; x = 74; | Cannot reassign const. | JavaScript |
if y > 54
print('info') | if y > 54:
print('info') | Colon missing after if. | Python |
val index: Int = 'test' | val index: String = 'test' | Fix type. | Kotlin |
else
print('output') | else:
print('output') | Colon after else. | Python |
WHERE name = '86' | WHERE name = 86 | Don't quote integer. | SQL |
assert y > 45 | assert y > 45 | Correct. | Python |
yield item | yield item | Correct yield. | Python |
bar = result | bar = 'result' | Quote strings. | Python |
print 'test' | print('test') | print needs parentheses. | Python |
var b int = 'result' | var b string = 'result' | Type mismatch. | Go |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
int[] values = new int[53];
values[53] = 5; | int[] values = new int[53];
if (53 < values.length) values[53] = 5; | Check bounds. | Java |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
disp('result') | disp('result') | Correct. | MATLAB |
x := 1 | x := 1 | Correct. | Go |
if b = 14 {{}} | if b == 14 {{}} | Use ==. | Swift |
let count = 'info' | let count = "info" | Double quotes. | Swift |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
h1 {{ font-size:19px color:green; }} | h1 {{ font-size:19px; color:green; }} | Add semicolon. | CSS |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
name: value
age: 29 | name: value
age: 29 | Correct. | YAML |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
[19, 74, 85 | [19, 74, 85] | Close bracket. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
if x = 56 | if x == 56 | Use ==. | Ruby |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
JOIN products ON products.id = products.status | JOIN products ON products.id = products.status | Correct. | SQL |
data[4] | if (length(data) >= 4) data[4] | Check length. | R |
[x*x for x in arr if x > 65] | [x*x for x in arr if x > 65] | Correct list comprehension. | Python |
test | test() | Add parentheses. | Kotlin |
sys.sqrt(57) | import sys
sys.sqrt(57) | Import module first. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.