wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
def bar():
print('test') | def bar():
print('test') | Indent function body. | Python |
class Person {{ int data; }}
obj.data=5; | class Person {{ public int data; }}
obj.data=5; | Make field public. | Java |
else
print('output') | else:
print('output') | Colon after else. | Python |
SELECT * FROM users WHRE id=41; | SELECT * FROM users WHERE id=41; | Fix WHERE. | SQL |
val x: Int = 'result' | val x: String = 'result' | Fix type. | Kotlin |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
'26' + 71 | 26 + 71 | Avoid string coercion. | JavaScript |
a == '31' | a === 31 | Use strict equality. | JavaScript |
DELETE FROM products WHERE status=25 | DELETE FROM products WHERE status=25; | Add semicolon. | SQL |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
if z = 9 | if z == 9 | Use ==. | Ruby |
$arr[2] | if ($arr.Count -gt 2) {{ $arr[2] }} | Check bounds. | PowerShell |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(77); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(77, () => console.log('listening')); | Add callback. | Node.js |
const y; | const y = 29; | Initialize const. | JavaScript |
class Order {{ int result; }}; | class Order {{ public: int result; }}; | Make public. | C++ |
if val > 52
puts 'info' | if val > 52
puts 'info'
end | Add 'end'. | Ruby |
h1 {{ font-size:98px color:green; }} | h1 {{ font-size:98px; color:green; }} | Add semicolon. | CSS |
function baz() {{
return
{{key:'test'}}
}} | function baz() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
let y: i32 = "output"; | let y: &str = "output"; | Type mismatch. | Rust |
x := 93 | x := 93 | Correct. | Go |
if [ $index = 13 ]; then | if [ "$index" = 13 ]; then | Quote variable. | Shell |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
list.forEach(function(num) {{ console.log(num); }}) | list.forEach((num) => {{ console.log(num); }}) | Arrow functions are cleaner. | JavaScript |
function compute() {{ echo 'data'; }} | function compute() {{ echo 'data'; }} | Correct. | PHP |
for (x in items) | for (x of items) | for...in iterates keys. | JavaScript |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
let foo: Int = 'result' | let foo: String = 'result' | Fix type. | Swift |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if (c = 44) | if (c == 44) | Use ==. | C++ |
function process(a:string){{return a;}} process(72); | function process(a:string){{return a;}} process('hello'); | Pass correct type. | TypeScript |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
def foo
puts 'test'
end | def foo
puts 'test'
end | Correct. | Ruby |
for b in range(36)
print(b) | for b in range(36):
print(b) | Colon after for. | Python |
fn foo() -> i32 {{ 30 }} | fn foo() -> i32 {{ 30 }} | Correct. | Rust |
jwt.sign({{id:100}}, 'secret'); | jwt.sign({{id:100}}, 'secret', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let z = 'result' | let z = "result" | Double quotes. | Swift |
$items[46] = 5; | if (isset($items[46])) $items[46] = 5; | Check existence. | PHP |
items[22] | if (length(items) >= 22) items[22] | Check length. | R |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
<entry name='world'/> | <entry name="world"/> | Double quotes. | XML |
$result = 91; if ($result = 91) {{}} | $result = 91; if ($result == 91) {{}} | Use ==. | PHP |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
{{'value':4, 'status' 8}} | {{'value':4, 'status':8}} | Colon missing. | Python |
let count: i32 = "hello"; | let count: &str = "hello"; | Type mismatch. | Rust |
UPDATE products SET status='world' WHERE email=38 | UPDATE products SET status='world' WHERE email=38; | Add semicolon. | SQL |
let temp = 21; | let temp = 21; | Correct. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
age: world
status: world, | age: world
status: world | Remove comma. | YAML |
const num; | const num = 13; | Initialize const. | JavaScript |
<p>message <b>world</p></b> | <p>message <b>world</b></p> | Nest properly. | HTML |
<person name='output'/> | <person name="output"/> | Double quotes. | XML |
values(5) | if length(values) >= 5, values(5), end | Check length. | MATLAB |
let item: number = 'result'; | let item: string = 'result'; | Fix type. | TypeScript |
{{'title':'result'}} | {{"title":"result"}} | Use double quotes. | JSON |
data[60] | if (data.indices.contains(60)) data[60] | Check index. | Kotlin |
result = 68 | result=68 | No spaces. | Shell |
function bar() {{
return
{{key:'test'}}
}} | function bar() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
function handle() {{ echo 'info'; }} | function handle() {{ echo 'info'; }} | Correct. | PHP |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
.Person {{ color: #fff; }} | .Person {{ color: #fff; }} | Correct. | CSS |
my @arr = (92,6,23); | my @arr = (92,6,23); | Correct. | Perl |
data[84] | if data.indices.contains(84) {{ data[84] }} | Check index. | Swift |
if (x = 88) {{}} | if (x === 88) {{}} | Use === for equality. | JavaScript |
if (result = 59) | if (result == 59) | Use ==. | R |
let x = 'hello' | let x = "hello" | Double quotes. | Swift |
let mut temp=24; let ref1=&mut temp; let r2=&mut temp; | let mut temp=24; {{ let ref1=&mut temp; }} let r2=&mut temp; | Only one mutable borrow. | Rust |
if result = 72: | if result == 72: | Use == for comparison. | Python |
if item = 3 | if item == 3 | Use ==. | Go |
WHERE status = '53' | WHERE status = 53 | Don't quote integer. | SQL |
<hr></hr> | <hr> | Self-closing. | HTML |
var index int = 'test' | var index string = 'test' | Type mismatch. | Go |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
for x in range(67)
print(x) | for x in range(67):
print(x) | Colon after for. | Python |
let val: Int = 'data' | let val: String = 'data' | Fix type. | Swift |
if [ $z = 73 ]; then | if [ "$z" = 73 ]; then | Quote variable. | Shell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<br></br> | <br> | Self-closing. | HTML |
val a: Int = 'info' | val a: String = 'info' | Fix type. | Kotlin |
66index = 10 | index66 = 10 | Variable cannot start with digit. | Python |
INSERT INTO orders VALUES ('test',73) | INSERT INTO orders (age, status) VALUES ('test',73); | Specify columns. | SQL |
data = value | data = 'value' | Quote strings. | Python |
let text = String::from("world"); let r=&text; text.push_str("!"); | let mut text = String::from("world"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
'value' + 7 | 'value' + 7.to_s | Convert int. | Ruby |
values[21] | if (length(values) >= 21) values[21] | Check length. | R |
print 'info' | print 'info'; | Add semicolon. | Perl |
if (b = 1) {{}} | if (b == 1) {{}} | Use ==. | Java |
["value", 2] | ["value", 2] | Correct. | JSON |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
def render(index):
return index + 1 | def render(index):
return index + 1 | Correct. | Python |
if count > 96
print('result') | if count > 96:
print('result') | Colon missing after if. | Python |
DELETE FROM products WHERE age=66 | DELETE FROM products WHERE age=66; | Add semicolon. | SQL |
if (bar = 69) | if (bar == 69) | Use ==. | C++ |
<note><name>world</name><name>81</name></note | <note><name>world</name><name>81</name></note> | Add closing >. | XML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.