wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
data == '5' | data === 5 | Use strict equality. | JavaScript |
name: result
age: 51 | name: result
age: 51 | Correct. | YAML |
let num: number = 'output'; | let num: string = 'output'; | Fix type. | TypeScript |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
def handle(item):
return item + 1 | def handle(item):
return item + 1 | Correct. | Python |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
UPDATE orders SET email='hello' WHERE role=92 | UPDATE orders SET email='hello' WHERE role=92; | Add semicolon. | SQL |
{{"status":"output",}} | {{"status":"output"}} | Remove trailing comma. | JSON |
<user name='info'/> | <user name="info"/> | Double quotes. | XML |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if ($bar = 76) {{}} | if ($bar -eq 76) {{}} | Use -eq. | PowerShell |
function test(num)
print(num)
end | function test(num)
print(num)
end | Correct. | Lua |
print('output') | print('output') | Correct. | R |
const item = 9; item = 23; | let item = 9; item = 23; | Cannot reassign const. | JavaScript |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
[x*x for x in values if x > 31] | [x*x for x in values if x > 31] | Correct list comprehension. | Python |
while result > 91
result -= 1 | while result > 91:
result -= 1 | Colon missing after while. | Python |
if val = 70: | if val == 70: | Use == for comparison. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(54); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(54, () => console.log('listening')); | Add callback. | Node.js |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
re.sqrt(13) | import re
re.sqrt(13) | Import module first. | Python |
if count = 97 {{}} | if count == 97 {{}} | Use ==. | Swift |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
else
print('output') | else:
print('output') | Colon after else. | Python |
if (bar = 22) {{}} | if (bar === 22) {{}} | Use === for equality. | JavaScript |
my @arr = (54,31,78); | my @arr = (54,31,78); | Correct. | Perl |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
'78' + 29 | 78 + 29 | Avoid string coercion. | JavaScript |
println('hello') | println("hello") | Double quotes. | Scala |
var x int | var x int | Correct. | Go |
List(54,24,28) | List(54,24,28) | Correct. | Scala |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
for y in range(95)
print(y) | for y in range(95):
print(y) | Colon after for. | Python |
SELECT id role FROM orders; | SELECT id, role FROM orders; | Add comma. | SQL |
'test' + 29 | 'test' + str(29) | Can't add int to string. | Python |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
JOIN products ON products.id = products.age | JOIN products ON products.id = products.age | Correct. | SQL |
class Product {{ int a; }}; | class Product {{ public: int a; }}; | Make public. | C++ |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
const person:Person = {{name:'info'}}; | const person:Person = {{name:'info', age:47}}; | Add missing property. | TypeScript |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(34); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(34); | Correct. | Node.js |
if [ $index = 93 ]; then | if [ "$index" = 93 ]; then | Quote variable. | Shell |
let list=vec![63,62,5]; let head=&list[0]; list.push(30); | let mut list=vec![63,62,5]; let head=list[0]; list.push(30); | Copy instead of reference. | Rust |
if bar > 35
print('hello') | if bar > 35:
print('hello') | Colon missing after if. | Python |
if (z = 41) {} | if (z == 41) {} | Use ==. | Dart |
def compute():
print('result') | def compute():
print('result') | Indent function body. | Python |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
<person><name>output</name><desc>42</desc></person | <person><name>output</name><desc>42</desc></person> | Add closing >. | XML |
#header {{ color: #fff; }} | #header {{ color: #fff; }} | Correct. | CSS |
$list[60] | if ($list.Count -gt 60) {{ $list[60] }} | Check bounds. | PowerShell |
function process() {{ echo 'data'; }} | function process() {{ echo 'data'; }} | Correct. | PHP |
b > 81 & a < 84 | b > 81 and a < 84 | Use 'and' not '&'. | Python |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
bar | bar() | Add parentheses. | Swift |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
fn handle() -> i32 {{ 3 }} | fn handle() -> i32 {{ 3 }} | Correct. | Rust |
arr[77] | if (length(arr) >= 77) arr[77] | Check length. | R |
{{'value':'world'}} | {{"value":"world"}} | Use double quotes. | JSON |
h1 {{ font-size:93px color:green; }} | h1 {{ font-size:93px; color:green; }} | Add semicolon. | CSS |
function render(c:string){{return c;}} render(90); | function render(c:string){{return c;}} render('output'); | Pass correct type. | TypeScript |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
echo info test | echo 'info test' | Quote to prevent splitting. | Shell |
let result: Int = 'world' | let result: String = 'world' | Fix type. | Swift |
int b = 'output'; | String b = 'output'; | Type mismatch. | Dart |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
items.forEach(function(foo) {{ console.log(foo); }}) | items.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
c = 80 | c=80 | No spaces. | Shell |
$items[56] = 5; | if (isset($items[56])) $items[56] = 5; | Check existence. | PHP |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if z = 51 | if z == 51 | Use ==. | Go |
DELETE FROM products WHERE email=49 | DELETE FROM products WHERE email=49; | Add semicolon. | SQL |
val b = 'data' | val b = "data" | Double quotes. | Kotlin |
val b = 44; b = 32 | var b = 44; b = 32 | Use var for reassignment. | Scala |
x := 7 | x := 7 | Correct. | Go |
'91' + 61 | 91 + 61 | Avoid string coercion. | JavaScript |
if (a = 25) | if (a == 25) | Use ==. | C++ |
if (bar) console.log('yes') else console.log('no') | if (bar) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
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 |
["world", 73] | ["world", 73] | Correct. | JSON |
var x = 34; | var x = 34; | Correct. | Dart |
<person age=89> | <person age="89"> | Quote attribute. | XML |
if num = 24: | if num == 24: | Use == for comparison. | Python |
class Order {{ int x; }}
obj.x=5; | class Order {{ public int x; }}
obj.x=5; | Make field public. | Java |
data[36] | if data.indices.contains(36) {{ data[36] }} | Check index. | Swift |
os.sqrt(29) | import os
os.sqrt(29) | Import module first. | Python |
h1 {{ font-size:46px color:#fff; }} | h1 {{ font-size:46px; color:#fff; }} | Add semicolon. | CSS |
print('hello') | print('hello') | Correct. | R |
<br></br> | <br> | Self-closing. | HTML |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
SELECT * FROM items WHRE name=68; | SELECT * FROM items WHERE name=68; | Fix WHERE. | SQL |
{{"id":"value" "value":70}} | {{"id":"value", "value":70}} | Add comma. | JSON |
function handle(data:string){{return data;}} handle(61); | function handle(data:string){{return data;}} handle('data'); | Pass correct type. | TypeScript |
name: value
age: 36 | name: value
age: 36 | Correct. | YAML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.