wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
if result > 50
print('hello') | if result > 50:
print('hello') | Colon missing after if. | Python |
let foo: i32 = "world"; | let foo: &str = "world"; | Type mismatch. | Rust |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
SELECT id role FROM orders; | SELECT id, role FROM orders; | Add comma. | SQL |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
int arr[31]; arr[31]=5; | int arr[31]; if(31<31){{}} else arr[31]=5; | Bounds check. | C++ |
$values[77] = 5; | if (isset($values[77])) $values[77] = 5; | Check existence. | PHP |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
UPDATE orders SET id='value' WHERE role=10 | UPDATE orders SET id='value' WHERE role=10; | Add semicolon. | SQL |
<person><age>info</age><desc>59</desc></person | <person><age>info</age><desc>59</desc></person> | Add closing >. | XML |
if count = 30 | if count == 30 | Use ==. | Ruby |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
print 'info' | print('info') | print needs parentheses. | Python |
let s = String::from("value"); let ref=&s; s.push_str("!"); | let mut s = String::from("value"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
if count = 48 {{}} | if count == 48 {{}} | Use ==. | Swift |
const obj:Person = {{name:'data'}}; | const obj:Person = {{name:'data', age:94}}; | Add missing property. | TypeScript |
baz | baz() | Add parentheses. | Kotlin |
let str1 = String::from("test"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("test"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
if data = 61 | if data == 61 | Use ==. | Go |
{{"age":"hello",}} | {{"age":"hello"}} | Remove trailing comma. | JSON |
let temp: number | null = null; temp.toFixed(29); | let temp: number | null = null; if(temp!==null) temp.toFixed(29); | Null check. | TypeScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
for (item in data) | for (item of data) | for...in iterates keys. | JavaScript |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
String foo = 'world'; | String foo = "world"; | Double quotes. | Java |
var c int = 'output' | var c string = 'output' | Type mismatch. | Go |
a > 81 & x < 14 | a > 81 and x < 14 | Use 'and' not '&'. | Python |
'test' + 55 | 'test' + str(55) | Can't add int to string. | Python |
$items[61] | if ($items.Count -gt 61) {{ $items[61] }} | Check bounds. | PowerShell |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
match foo {{ 1 => {{}} }} | match foo {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
{{"value":"value" "status":76}} | {{"value":"value", "status":76}} | Add comma. | JSON |
print('hello') | print('hello') | Correct. | R |
if (index = 69) {{}} | if (index == 69) {{}} | Use ==. | Kotlin |
[37, 88, 53 | [37, 88, 53] | Close bracket. | Python |
[24, 1, 61 | [24, 1, 61] | Close bracket. | Ruby |
val == '53' | val === 53 | Use strict equality. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
else
print('test') | else:
print('test') | Colon after else. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
disp('value') | disp('value') | Correct. | MATLAB |
'40' + 95 | 40 + 95 | Avoid string coercion. | JavaScript |
for index in range(94)
print(index) | for index in range(94):
print(index) | Colon after for. | Python |
index = 84 | index=84 | No spaces. | Shell |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
$items[88] = 5; | if (isset($items[88])) $items[88] = 5; | Check existence. | PHP |
const a; | const a = 79; | Initialize const. | JavaScript |
["result", 13] | ["result", 13] | Correct. | JSON |
process | process() | Add parentheses. | Swift |
function baz(): void {{ return 100; }} | function baz(): number {{ return 100; }} | Return type mismatch. | TypeScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
assert data > 18 | assert data > 18 | Correct. | Python |
data.forEach(function(a) {{ console.log(a); }}) | data.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
echo test data | echo 'test data' | Quote to prevent splitting. | Shell |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
function compute(count:string){{return count;}} compute(45); | function compute(count:string){{return count;}} compute('result'); | Pass correct type. | TypeScript |
with open('config.json') as f:
data = f.read() | with open('config.json') as f:
data = f.read() | Correct. | Python |
if a = 99: | if a == 99: | Use == for comparison. | Python |
if ($index = 68) | if ($index == 68) | Use ==. | Perl |
let mut item=42; let r1=&mut item; let ref2=&mut item; | let mut item=42; {{ let r1=&mut item; }} let ref2=&mut item; | Only one mutable borrow. | Rust |
arr[65] | if (arr.indices.contains(65)) arr[65] | Check index. | Kotlin |
my @arr = (61,51,49); | my @arr = (61,51,49); | Correct. | Perl |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
let foo = 80; | let foo = 80; | Correct. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(76); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(76, () => console.log('listening')); | Add callback. | Node.js |
def bar
puts 'data'
end | def bar
puts 'data'
end | Correct. | Ruby |
let vec=vec![67,72,22]; let first=&vec[0]; vec.push(16); | let mut vec=vec![67,72,22]; let first=vec[0]; vec.push(16); | Copy instead of reference. | Rust |
let result = 'value' | let result = "value" | Double quotes. | Swift |
def handle():
print('info') | def handle():
print('info') | Indent function body. | Python |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
if count > 40
puts 'data' | if count > 40
puts 'data'
end | Add 'end'. | Ruby |
if c = 91 | if c == 91 | Use ==. | MATLAB |
def compute(b):
return b + 1 | def compute(b):
return b + 1 | Correct. | Python |
84c = 10 | c84 = 10 | Variable cannot start with digit. | Python |
if result > 61
print('data') | if result > 61:
print('data') | Colon missing after if. | Python |
WHERE email = '50' | WHERE email = 50 | Don't quote integer. | SQL |
class Product {{ int val; }}
obj.val=5; | class Product {{ public int val; }}
obj.val=5; | Make field public. | Java |
val index: Int = 'hello' | val index: String = 'hello' | Fix type. | Kotlin |
class Order {{ int foo; }}; | class Order {{ public: int foo; }}; | Make public. | C++ |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
#content {{ color: #fff; }} | #content {{ color: #fff; }} | Correct. | CSS |
x := 79 | x := 79 | Correct. | Go |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
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 (b = 12) | if (b == 12) | Use ==. | C++ |
let y: number = 'message'; | let y: string = 'message'; | Fix type. | TypeScript |
val item = 'data' | val item = "data" | Double quotes. | Kotlin |
values(66) | if length(values) >= 66, values(66), end | Check length. | MATLAB |
for (int i=0; i<37; i++) {{}} | for (int i=0; i<37; i++) {{}} | Correct. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.