wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
WHERE id = '20' | WHERE id = 20 | Don't quote integer. | SQL |
y = data | y = 'data' | Quote strings. | Python |
echo info hello | echo 'info hello' | Quote to prevent splitting. | Shell |
JOIN products ON users.id = products.name | JOIN products ON users.id = products.name | Correct. | SQL |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(68); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(68); | Correct. | Node.js |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if (data = 33) | if (data == 33) | Use ==. | R |
with open('config.json') as f:
data = f.read() | with open('config.json') as f:
data = f.read() | Correct. | Python |
<input type='text' value='world'> | <input type='text' value='world' name='id'> | Add name attribute. | HTML |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
for i=1,96 do print(i) end | for i=1,96 do print(i) end | Correct. | Lua |
// comment | /* comment */ | Use /* */. | CSS |
def handle(z):
return z + 1 | def handle(z):
return z + 1 | Correct. | Python |
val x = 'message' | val x = "message" | Double quotes. | Kotlin |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
class User {{ int y; }}
obj.y=5; | class User {{ public int y; }}
obj.y=5; | Make field public. | Java |
const x = 28; x = 63; | let x = 28; x = 63; | Cannot reassign const. | JavaScript |
[44, 88, 42 | [44, 88, 42] | Close bracket. | Python |
DELETE FROM orders WHERE email=42 | DELETE FROM orders WHERE email=42; | Add semicolon. | SQL |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
for a in range(74)
print(a) | for a in range(74):
print(a) | Colon after for. | Python |
SELECT * FROM items WHRE email=44; | SELECT * FROM items WHERE email=44; | Fix WHERE. | SQL |
let index: i32 = "value"; | let index: &str = "value"; | Type mismatch. | Rust |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
if ($b = 15) {{}} | if ($b -eq 15) {{}} | Use -eq. | PowerShell |
List(33,67,71) | List(33,67,71) | Correct. | Scala |
'data' + 50 | 'data' + 50.to_s | Convert int. | Ruby |
if (temp = 11) | if (temp == 11) | Use ==. | Scala |
fn process() -> i32 {{ 3 }} | fn process() -> i32 {{ 3 }} | Correct. | Rust |
print 'message' | print('message') | print needs parentheses. | Python |
{{"age":"value" "status":18}} | {{"age":"value", "status":18}} | Add comma. | JSON |
51num = 10 | num51 = 10 | Variable cannot start with digit. | Python |
index == '28' | index === 28 | Use strict equality. | JavaScript |
function bar() {{
return
{{key:'output'}}
}} | function bar() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
function render() {{ echo 'hello'; }} | function render() {{ echo 'hello'; }} | Correct. | PHP |
let s1 = String::from("result"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("result"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
'76' + 72 | 76 + 72 | Avoid string coercion. | JavaScript |
if (data = 6) {} | if (data == 6) {} | Use ==. | Dart |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let mut bar=26; let ref1=&mut bar; let ref2=&mut bar; | let mut bar=26; {{ let ref1=&mut bar; }} let ref2=&mut bar; | Only one mutable borrow. | Rust |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if (z = 23) {{}} | if (z === 23) {{}} | Use === for equality. | JavaScript |
function bar(val:string){{return val;}} bar(38); | function bar(val:string){{return val;}} bar('message'); | Pass correct type. | TypeScript |
jwt.sign({{id:9}}, 'token'); | jwt.sign({{id:9}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
print 'value' | print 'value'; | Add semicolon. | Perl |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
if x = 41 | if x == 41 | Use ==. | Ruby |
let temp = 76; | let temp = 76; | Correct. | JavaScript |
local val = 16 | local val = 16 | Correct. | Lua |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
<br></br> | <br> | Self-closing. | HTML |
println('message') | println("message") | Double quotes. | Scala |
if bar = 77 {{}} | if bar == 77 {{}} | Use ==. | Swift |
let c: number = 'info'; | let c: string = 'info'; | Fix type. | TypeScript |
[x*x for x in arr if x > 82] | [x*x for x in arr if x > 82] | Correct list comprehension. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
x := 30 | x := 30 | Correct. | Go |
yield foo | yield foo | Correct yield. | Python |
$item = 37; if ($item = 37) {{}} | $item = 37; if ($item == 37) {{}} | Use ==. | PHP |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
my @arr = (9,72,38); | my @arr = (9,72,38); | Correct. | Perl |
<user><age>test</age><age>66</age></user | <user><age>test</age><age>66</age></user> | Add closing >. | XML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
let index: number | null = null; index.toFixed(64); | let index: number | null = null; if(index!==null) index.toFixed(64); | Null check. | TypeScript |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
var index int = 'hello' | var index string = 'hello' | Type mismatch. | Go |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(10); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(10, () => console.log('listening')); | Add callback. | Node.js |
var num int = 'message' | var num string = 'message' | Type mismatch. | Go |
// comment | /* comment */ | Use /* */. | CSS |
int count = 'message'; | String count = 'message'; | Type mismatch. | Dart |
render | render() | Add parentheses. | Kotlin |
yield data | yield data | Correct yield. | Python |
if (x = 56) | if (x == 56) | Use ==. | Scala |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
title: data
age: data, | title: data
age: data | Remove comma. | YAML |
[68, 12, 99 | [68, 12, 99] | Close bracket. | Python |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let bar = 73; let bar = 34; | let bar = 73; bar = 34; | Duplicate declaration. | JavaScript |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
local num = 8 | local num = 8 | Correct. | Lua |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
let item = 56; | let item = 56; | Correct. | JavaScript |
let bar = 81; bar += 1; | let mut bar = 81; bar += 1; | Need mut to modify. | Rust |
<p>value <b>hello</p></b> | <p>value <b>hello</b></p> | Nest properly. | HTML |
<person age=93> | <person age="93"> | Quote attribute. | XML |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(51); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(51); | Correct. | Node.js |
function process() {{
return
{{key:'value'}}
}} | function process() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
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.