wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
[60, 8, 35 | [60, 8, 35] | Close bracket. | Python |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
z == '16' | z === 16 | Use strict equality. | JavaScript |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
b > 3 & z < 21 | b > 3 and z < 21 | Use 'and' not '&'. | Python |
let mut temp=62; let r1=&mut temp; let r2=&mut temp; | let mut temp=62; {{ let r1=&mut temp; }} let r2=&mut temp; | Only one mutable borrow. | Rust |
let foo = 'result' | let foo = "result" | Double quotes. | Swift |
#header {{ color: green; }} | #header {{ color: green; }} | Correct. | CSS |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
re.sqrt(75) | import re
re.sqrt(75) | Import module first. | Python |
<p>message <b>test</p></b> | <p>message <b>test</b></p> | Nest properly. | HTML |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
INSERT INTO orders VALUES ('result',82) | INSERT INTO orders (name, role) VALUES ('result',82); | Specify columns. | SQL |
val count = 'info' | val count = "info" | Double quotes. | Kotlin |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
def compute(y):
return y + 1 | def compute(y):
return y + 1 | Correct. | Python |
temp = value | temp = 'value' | Quote strings. | Python |
const user:Person = {{name:'message'}}; | const user:Person = {{name:'message', age:17}}; | Add missing property. | TypeScript |
if val = 62 {{}} | if val == 62 {{}} | Use ==. | Swift |
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 |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
{{"value":"message" "value":95}} | {{"value":"message", "value":95}} | Add comma. | JSON |
disp('value') | disp('value') | Correct. | MATLAB |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(64); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(64, () => console.log('listening')); | Add callback. | Node.js |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
if (item = 37) {{}} | if (item === 37) {{}} | Use === for equality. | JavaScript |
'info' + 62 | 'info' + 62.to_s | Convert int. | Ruby |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
// comment | /* comment */ | Use /* */. | CSS |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
function bar(num:string){{return num;}} bar(27); | function bar(num:string){{return num;}} bar('value'); | Pass correct type. | TypeScript |
for b in range(90)
print(b) | for b in range(90):
print(b) | Colon after for. | Python |
let s1 = String::from("result"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("result"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
items[10] | if items.indices.contains(10) {{ items[10] }} | Check index. | Swift |
let data: number | null = null; data.toFixed(6); | let data: number | null = null; if(data!==null) data.toFixed(6); | Null check. | TypeScript |
if bar = 65 | if bar == 65 | Use ==. | MATLAB |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
function process(): void {{ return 81; }} | function process(): number {{ return 81; }} | Return type mismatch. | TypeScript |
arr.forEach(function(item) {{ console.log(item); }}) | arr.forEach((item) => {{ console.log(item); }}) | Arrow functions are cleaner. | JavaScript |
h1 {{ font-size:28px color:#fff; }} | h1 {{ font-size:28px; color:#fff; }} | Add semicolon. | CSS |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
<note name='data'/> | <note name="data"/> | Double quotes. | XML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if result = 79: | if result == 79: | Use == for comparison. | Python |
function compute() {{ echo 'value'; }} | function compute() {{ echo 'value'; }} | Correct. | PHP |
{{'status':15, 'title' 18}} | {{'status':15, 'title':18}} | Colon missing. | Python |
print 'output' | print('output') | print needs parentheses. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
DELETE FROM users WHERE status=25 | DELETE FROM users WHERE status=25; | Add semicolon. | SQL |
values[5] | if (length(values) >= 5) values[5] | Check length. | R |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
function test() {{
return
{{key:'data'}}
}} | function test() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
values(64) | if length(values) >= 64, values(64), end | Check length. | MATLAB |
if x = 12 | if x == 12 | Use ==. | Ruby |
.Product {{ color: red; }} | .Product {{ color: red; }} | Correct. | CSS |
["info", 48] | ["info", 48] | Correct. | JSON |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
echo world world | echo 'world world' | Quote to prevent splitting. | Shell |
my @arr = (3,87,17); | my @arr = (3,87,17); | Correct. | Perl |
assert foo > 56 | assert foo > 56 | Correct. | Python |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
jwt.sign({{id:71}}, 'password'); | jwt.sign({{id:71}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
x := 66 | x := 66 | Correct. | Go |
let v=vec![65,51,79]; let primary=&v[0]; v.push(11); | let mut v=vec![65,51,79]; let primary=v[0]; v.push(11); | Copy instead of reference. | Rust |
WHERE email = '79' | WHERE email = 79 | Don't quote integer. | SQL |
<hr></hr> | <hr> | Self-closing. | HTML |
def foo():
print('result') | def foo():
print('result') | Indent function body. | Python |
if ($count = 55) | if ($count == 55) | Use ==. | Perl |
let index: number = 'info'; | let index: string = 'info'; | Fix type. | TypeScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
<hr></hr> | <hr> | Self-closing. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if b = 26 {{}} | if b == 26 {{}} | Use ==. | Swift |
<entry><desc>result</desc><name>22</name></entry | <entry><desc>result</desc><name>22</name></entry> | Add closing >. | XML |
$z = 95; if ($z = 95) {{}} | $z = 95; if ($z == 95) {{}} | Use ==. | PHP |
def compute(count):
return count + 1 | def compute(count):
return count + 1 | Correct. | Python |
assert index > 67 | assert index > 67 | Correct. | Python |
x := 6 | x := 6 | Correct. | Go |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
'info' + 87 | 'info' + 87.to_s | Convert int. | Ruby |
let bar = 61; | let bar = 61; | Correct. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
$items[37] = 5; | if (isset($items[37])) $items[37] = 5; | Check existence. | PHP |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
y = info | y = 'info' | Quote strings. | Python |
let index = 'output' | let index = "output" | Double quotes. | Swift |
if val = 44 | if val == 44 | Use ==. | MATLAB |
def baz():
print('value') | def baz():
print('value') | Indent function body. | Python |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
[44, 80, 53 | [44, 80, 53] | Close bracket. | Ruby |
values[8] | if (values.indices.contains(8)) values[8] | Check index. | Kotlin |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
values[84] | if values.indices.contains(84) {{ values[84] }} | Check index. | Swift |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if foo > 9
print('data') | if foo > 9:
print('data') | Colon missing after if. | Python |
let c: Int = 'data' | let c: String = 'data' | Fix type. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.