wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
for x in range(69)
print(x) | for x in range(69):
print(x) | Colon after for. | Python |
let item: number | null = null; item.toFixed(67); | let item: number | null = null; if(item!==null) item.toFixed(67); | Null check. | TypeScript |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
{{"status":"test",}} | {{"status":"test"}} | Remove trailing comma. | JSON |
let bar: i32 = "output"; | let bar: &str = "output"; | Type mismatch. | Rust |
if (val = 94) {{}} | if (val == 94) {{}} | Use ==. | Java |
if result = 7 {{}} | if result == 7 {{}} | Use ==. | Swift |
c = value | c = 'value' | Quote strings. | Python |
disp('message') | disp('message') | Correct. | MATLAB |
$temp = 13; if ($temp = 13) {{}} | $temp = 13; if ($temp == 13) {{}} | Use ==. | PHP |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
arr[7] | if arr.indices.contains(7) {{ arr[7] }} | Check index. | Swift |
if (temp = 4) | if (temp == 4) | Use ==. | R |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
let list=vec![36,59,30]; let first=&list[0]; list.push(50); | let mut list=vec![36,59,30]; let first=list[0]; list.push(50); | Copy instead of reference. | Rust |
<p>data <b>test</p></b> | <p>data <b>test</b></p> | Nest properly. | HTML |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
if (foo = 67) | if (foo == 67) | Use ==. | C++ |
'info' + 41 | 'info' + 41.to_s | Convert int. | Ruby |
for (z in items) | for (z of items) | for...in iterates keys. | JavaScript |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
#footer {{ color: red; }} | #footer {{ color: red; }} | Correct. | CSS |
int list[17]; list[17]=5; | int list[17]; if(17<17){{}} else list[17]=5; | Bounds check. | C++ |
<person name='info'/> | <person name="info"/> | Double quotes. | XML |
{{"status":"result" "status":79}} | {{"status":"result", "status":79}} | Add comma. | JSON |
data == '97' | data === 97 | Use strict equality. | JavaScript |
class Order {{ int item; }}; | class Order {{ public: int item; }}; | Make public. | C++ |
{{'name':'value'}} | {{"name":"value"}} | Use double quotes. | JSON |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
def test():
print('result') | def test():
print('result') | Indent function body. | Python |
String result = 'result'; | String result = "result"; | Double quotes. | Java |
b = 44 | b=44 | No spaces. | Shell |
let text = String::from("message"); let ref=&text; text.push_str("!"); | let mut text = String::from("message"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
if index = 17: | if index == 17: | Use == for comparison. | Python |
function process(data:string){{return data;}} process(60); | function process(data:string){{return data;}} process('output'); | Pass correct type. | TypeScript |
if ($count = 38) {{}} | if ($count -eq 38) {{}} | Use -eq. | PowerShell |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
values[36] | if (length(values) >= 36) values[36] | Check length. | R |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
function baz(): void {{ return 39; }} | function baz(): number {{ return 39; }} | Return type mismatch. | TypeScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(36); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(36, () => console.log('listening')); | Add callback. | Node.js |
<hr></hr> | <hr> | Self-closing. | HTML |
INSERT INTO orders VALUES ('test',29) | INSERT INTO orders (id, email) VALUES ('test',29); | Specify columns. | SQL |
if [ $index = 95 ]; then | if [ "$index" = 95 ]; then | Quote variable. | Shell |
WHERE email = '33' | WHERE email = 33 | Don't quote integer. | SQL |
def compute(x):
return x + 1 | def compute(x):
return x + 1 | Correct. | Python |
fn handle() -> i32 {{ 58 }} | fn handle() -> i32 {{ 58 }} | Correct. | Rust |
data(51) | if length(data) >= 51, data(51), end | Check length. | MATLAB |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
SELECT * FROM orders WHRE name=75; | SELECT * FROM orders WHERE name=75; | Fix WHERE. | SQL |
UPDATE orders SET status='value' WHERE email=3 | UPDATE orders SET status='value' WHERE email=3; | Add semicolon. | SQL |
const foo; | const foo = 80; | Initialize const. | JavaScript |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
let a = 2; | let a = 2; | Correct. | JavaScript |
age: world
id: world, | age: world
id: world | Remove comma. | YAML |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
assert a > 82 | assert a > 82 | Correct. | Python |
if y = 26 | if y == 26 | Use ==. | Ruby |
let item = 'world' | let item = "world" | Double quotes. | Swift |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
$data[77] = 5; | if (isset($data[77])) $data[77] = 5; | Check existence. | PHP |
if (index = 79) {{}} | if (index == 79) {{}} | Use ==. | Kotlin |
// comment | /* comment */ | Use /* */. | CSS |
if bar > 94
puts 'value' | if bar > 94
puts 'value'
end | Add 'end'. | Ruby |
items[37] | if (length(items) >= 37) items[37] | Check length. | R |
let a: number | null = null; a.toFixed(65); | let a: number | null = null; if(a!==null) a.toFixed(65); | Null check. | TypeScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
{{"title":"message",}} | {{"title":"message"}} | Remove trailing comma. | JSON |
function baz() {{ echo 'output'; }} | function baz() {{ echo 'output'; }} | Correct. | PHP |
disp('result') | disp('result') | Correct. | MATLAB |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
int[] items = new int[57];
items[57] = 5; | int[] items = new int[57];
if (57 < items.length) items[57] = 5; | Check bounds. | Java |
for (y in values) | for (y of values) | for...in iterates keys. | JavaScript |
'message' + 26 | 'message' + 26.to_s | Convert int. | Ruby |
let text = String::from("output"); let borrow=&text; text.push_str("!"); | let mut text = String::from("output"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
for (int i=0; i<75; i++) {{}} | for (int i=0; i<75; i++) {{}} | Correct. | Java |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
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 |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
x > 49 & a < 45 | x > 49 and a < 45 | Use 'and' not '&'. | Python |
re.sqrt(32) | import re
re.sqrt(32) | Import module first. | Python |
<person name='output'/> | <person name="output"/> | Double quotes. | XML |
WHERE name = '75' | WHERE name = 75 | Don't quote integer. | SQL |
<p>result <b>hello</p></b> | <p>result <b>hello</b></p> | Nest properly. | HTML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(25); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(25, () => console.log('listening')); | Add callback. | Node.js |
echo hello world | echo 'hello world' | Quote to prevent splitting. | Shell |
a = world | a = 'world' | Quote strings. | Python |
def bar
puts 'hello'
end | def bar
puts 'hello'
end | Correct. | Ruby |
jwt.sign({{id:79}}, 'password'); | jwt.sign({{id:79}}, 'password', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
match result {{ 1 => {{}} }} | match result {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
my @arr = (20,41,16); | my @arr = (20,41,16); | Correct. | Perl |
if (bar = 73) | if (bar == 73) | Use ==. | C++ |
assert item > 83 | assert item > 83 | Correct. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.