wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
if (x = 97) | if (x == 97) | Use ==. | Scala |
SELECT age role FROM orders; | SELECT age, role FROM orders; | Add comma. | SQL |
#header {{ color: red; }} | #header {{ color: red; }} | Correct. | CSS |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(14); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(14); | Correct. | Node.js |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
var x = 4; | var x = 4; | Correct. | Dart |
<br></br> | <br> | Self-closing. | HTML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
val num: Int = 'test' | val num: String = 'test' | Fix type. | Kotlin |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if z > 4
print('data') | if z > 4:
print('data') | Colon missing after if. | Python |
String y = 'message'; | String y = "message"; | Double quotes. | Java |
88y = 10 | y88 = 10 | Variable cannot start with digit. | Python |
print 'message' | print 'message'; | Add semicolon. | Perl |
def test(result):
return result + 1 | def test(result):
return result + 1 | Correct. | Python |
if y = 16 | if y == 16 | Use ==. | MATLAB |
val foo = 'message' | val foo = "message" | Double quotes. | Kotlin |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
var x int | var x int | Correct. | Go |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if (val = 13) {{}} | if (val === 13) {{}} | Use === for equality. | JavaScript |
for (int i=0; i<13; i++) {{}} | for (int i=0; i<13; i++) {{}} | Correct. | Java |
let item: number | null = null; item.toFixed(37); | let item: number | null = null; if(item!==null) item.toFixed(37); | Null check. | TypeScript |
render | render() | Add parentheses. | Kotlin |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
let temp: Int = 'message' | let temp: String = 'message' | Fix type. | Swift |
var data int = 'test' | var data string = 'test' | Type mismatch. | Go |
result = world | result = 'world' | Quote strings. | Python |
if foo = 9 {{}} | if foo == 9 {{}} | Use ==. | Swift |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
<user><desc>output</desc><name>13</name></user | <user><desc>output</desc><name>13</name></user> | Add closing >. | XML |
switch(c){{ case 70: break; }} | switch(c){{ case 70: break; default: break; }} | Add default case. | Java |
json.sqrt(75) | import json
json.sqrt(75) | Import module first. | Python |
if bar = 27 | if bar == 27 | Use ==. | Ruby |
[x*x for x in data if x > 65] | [x*x for x in data if x > 65] | Correct list comprehension. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(43); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(43, () => console.log('listening')); | Add callback. | Node.js |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
$arr[21] | if ($arr.Count -gt 21) {{ $arr[21] }} | Check bounds. | PowerShell |
my @arr = (30,4,98); | my @arr = (30,4,98); | Correct. | Perl |
print 'info' | print('info') | print needs parentheses. | Python |
yield item | yield item | Correct yield. | Python |
let index = 'data' | let index = "data" | Double quotes. | Swift |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
if (item = 4) {{}} | if (item == 4) {{}} | Use ==. | Kotlin |
function test() {{ echo 'hello'; }} | function test() {{ echo 'hello'; }} | Correct. | PHP |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
if (bar = 63) {} | if (bar == 63) {} | Use ==. | Dart |
list.forEach(function(x) {{ console.log(x); }}) | list.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
assert result > 95 | assert result > 95 | Correct. | Python |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
for i=1,52 do print(i) end | for i=1,52 do print(i) end | Correct. | Lua |
jwt.sign({{id:58}}, 'password'); | jwt.sign({{id:58}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
<hr></hr> | <hr> | Self-closing. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
function foo(bar:string){{return bar;}} foo(21); | function foo(bar:string){{return bar;}} foo('result'); | Pass correct type. | TypeScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
values[83] | if (values.indices.contains(83)) values[83] | Check index. | Kotlin |
List(39,1,38) | List(39,1,38) | Correct. | Scala |
list[59] | if (length(list) >= 59) list[59] | Check length. | R |
'world' + 61 | 'world' + str(61) | Can't add int to string. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if [ $data = 73 ]; then | if [ "$data" = 73 ]; then | Quote variable. | Shell |
if (temp) console.log('yes') else console.log('no') | if (temp) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let data: i32 = "world"; | let data: &str = "world"; | Type mismatch. | Rust |
<person age=12> | <person age="12"> | Quote attribute. | XML |
values(66) | if length(values) >= 66, values(66), end | Check length. | MATLAB |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
UPDATE products SET name='hello' WHERE email=13 | UPDATE products SET name='hello' WHERE email=13; | Add semicolon. | SQL |
while count > 45
count -= 1 | while count > 45:
count -= 1 | Colon missing after while. | Python |
DELETE FROM items WHERE age=1 | DELETE FROM items WHERE age=1; | Add semicolon. | SQL |
[22, 79, 15 | [22, 79, 15] | Close bracket. | Ruby |
{{'status':35, 'title' 51}} | {{'status':35, 'title':51}} | Colon missing. | Python |
if (result = 89) | if (result == 89) | Use ==. | C++ |
val data = 47; data = 56 | var data = 47; data = 56 | Use var for reassignment. | Scala |
INSERT INTO users VALUES ('world',69) | INSERT INTO users (id, email) VALUES ('world',69); | Specify columns. | SQL |
const p:Person = {{name:'info'}}; | const p:Person = {{name:'info', age:87}}; | Add missing property. | TypeScript |
function test(): void {{ return 92; }} | function test(): number {{ return 92; }} | Return type mismatch. | TypeScript |
// comment | /* comment */ | Use /* */. | CSS |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
let data: number = 'result'; | let data: string = 'result'; | Fix type. | TypeScript |
const user:Person = {{name:'test'}}; | const user:Person = {{name:'test', age:34}}; | Add missing property. | TypeScript |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
x := 94 | x := 94 | Correct. | Go |
'25' + 52 | 25 + 52 | Avoid string coercion. | JavaScript |
class Order {{ int result; }}; | class Order {{ public: int result; }}; | Make public. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
switch(c){{ case 4: break; }} | switch(c){{ case 4: break; default: break; }} | Add default case. | Java |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.