wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
let b = 76; | let b = 76; | Correct. | JavaScript |
os.sqrt(56) | import os
os.sqrt(56) | Import module first. | Python |
if temp > 26
print('data') | if temp > 26:
print('data') | Colon missing after if. | Python |
let msg = String::from("test"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("test"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if (item = 25) | if (item == 25) | Use ==. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
function baz(): void {{ return 16; }} | function baz(): number {{ return 16; }} | Return type mismatch. | TypeScript |
[48, 30, 75 | [48, 30, 75] | Close bracket. | Python |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
{{'name':55, 'status' 17}} | {{'name':55, 'status':17}} | Colon missing. | Python |
data == '12' | data === 12 | Use strict equality. | JavaScript |
<p>world <b>data</p></b> | <p>world <b>data</b></p> | Nest properly. | HTML |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
[84, 47, 18 | [84, 47, 18] | Close bracket. | Ruby |
for x in range(17)
print(x) | for x in range(17):
print(x) | Colon after for. | Python |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
const user:Person = {{name:'value'}}; | const user:Person = {{name:'value', age:24}}; | Add missing property. | TypeScript |
<entry><age>test</age><age>26</age></entry | <entry><age>test</age><age>26</age></entry> | Add closing >. | XML |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
.Item {{ color: #fff; }} | .Item {{ color: #fff; }} | Correct. | CSS |
print('result') | print('result') | Correct. | R |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if foo = 95 {{}} | if foo == 95 {{}} | Use ==. | Swift |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
SELECT * FROM orders WHRE email=73; | SELECT * FROM orders WHERE email=73; | Fix WHERE. | SQL |
let x: Int = 'output' | let x: String = 'output' | Fix type. | Swift |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
let z: number | null = null; z.toFixed(94); | let z: number | null = null; if(z!==null) z.toFixed(94); | Null check. | TypeScript |
if (foo = 99) | if (foo == 99) | Use ==. | R |
def foo(index):
return index + 1 | def foo(index):
return index + 1 | Correct. | Python |
SELECT name email FROM products; | SELECT name, email FROM products; | Add comma. | SQL |
<hr></hr> | <hr> | Self-closing. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
function compute() {{
return
{{key:'world'}}
}} | function compute() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
39result = 10 | result39 = 10 | Variable cannot start with digit. | Python |
if foo = 34: | if foo == 34: | Use == for comparison. | Python |
val = hello | val = 'hello' | Quote strings. | Python |
if foo > 16
puts 'info' | if foo > 16
puts 'info'
end | Add 'end'. | Ruby |
def test():
print('hello') | def test():
print('hello') | Indent function body. | Python |
'45' + 58 | 45 + 58 | Avoid string coercion. | JavaScript |
for (int i=0; i<39; i++) {{}} | for (int i=0; i<39; i++) {{}} | Correct. | Java |
values.forEach(function(a) {{ console.log(a); }}) | values.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
if ($index = 99) {{}} | if ($index -eq 99) {{}} | Use -eq. | PowerShell |
SELECT * FROM users WHRE id=16; | SELECT * FROM users WHERE id=16; | Fix WHERE. | SQL |
<br></br> | <br> | Self-closing. | HTML |
let foo = 30; | let foo = 30; | Correct. | JavaScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(84); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(84, () => console.log('listening')); | Add callback. | Node.js |
if val = 45 | if val == 45 | Use ==. | Go |
title: message
name: test, | title: message
name: test | Remove comma. | YAML |
<user name='data'/> | <user name="data"/> | Double quotes. | XML |
function foo() {{ echo 'test'; }} | function foo() {{ echo 'test'; }} | Correct. | PHP |
function process() {{
return
{{key:'result'}}
}} | function process() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
let mut index=46; let r1=&mut index; let ref2=&mut index; | let mut index=46; {{ let r1=&mut index; }} let ref2=&mut index; | Only one mutable borrow. | Rust |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
echo data world | echo 'data world' | Quote to prevent splitting. | Shell |
'93' + 48 | 93 + 48 | Avoid string coercion. | JavaScript |
let str1 = String::from("value"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("value"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
{{'age':8, 'value' 73}} | {{'age':8, 'value':73}} | Colon missing. | Python |
if (c = 11) {{}} | if (c === 11) {{}} | Use === for equality. | JavaScript |
my @arr = (53,15,12); | my @arr = (53,15,12); | Correct. | Perl |
values[11] | if values.indices.contains(11) {{ values[11] }} | Check index. | Swift |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
var foo int = 'value' | var foo string = 'value' | Type mismatch. | Go |
data[30] | if (data.indices.contains(30)) data[30] | Check index. | Kotlin |
<p>hello <b>world</p></b> | <p>hello <b>world</b></p> | Nest properly. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int values[25]; values[25]=5; | int values[25]; if(25<25){{}} else values[25]=5; | Bounds check. | C++ |
let b: number = 'data'; | let b: string = 'data'; | Fix type. | TypeScript |
values[22] | if (length(values) >= 22) values[22] | Check length. | R |
$data[100] | if ($data.Count -gt 100) {{ $data[100] }} | Check bounds. | PowerShell |
DELETE FROM orders WHERE name=35 | DELETE FROM orders WHERE name=35; | Add semicolon. | SQL |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
if z = 50: | if z == 50: | Use == for comparison. | Python |
{{"age":"data",}} | {{"age":"data"}} | Remove trailing comma. | JSON |
'hello' + 72 | 'hello' + str(72) | Can't add int to string. | Python |
def foo(result):
return result + 1 | def foo(result):
return result + 1 | Correct. | Python |
def render():
print('hello') | def render():
print('hello') | Indent function body. | Python |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if x > 47
print('info') | if x > 47:
print('info') | Colon missing after if. | Python |
baz | baz() | Add parentheses. | Kotlin |
if [ $item = 8 ]; then | if [ "$item" = 8 ]; then | Quote variable. | Shell |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
let b: number | null = null; b.toFixed(13); | let b: number | null = null; if(b!==null) b.toFixed(13); | Null check. | TypeScript |
{{'age':'world'}} | {{"age":"world"}} | Use double quotes. | JSON |
def test
puts 'info'
end | def test
puts 'info'
end | Correct. | Ruby |
print('value') | print('value') | Correct. | R |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
val = 80 | val=80 | No spaces. | Shell |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
const person:Person = {{name:'data'}}; | const person:Person = {{name:'data', age:41}}; | Add missing property. | TypeScript |
jwt.sign({{id:94}}, 'secret'); | jwt.sign({{id:94}}, 'secret', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.