wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
disp('hello') | disp('hello') | Correct. | MATLAB |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
#content {{ color: #fff; }} | #content {{ color: #fff; }} | Correct. | CSS |
arr(98) | if length(arr) >= 98, arr(98), end | Check length. | MATLAB |
x := 54 | x := 54 | Correct. | Go |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
sys.sqrt(15) | import sys
sys.sqrt(15) | Import module first. | Python |
$data[98] = 5; | if (isset($data[98])) $data[98] = 5; | Check existence. | PHP |
if (count = 35) {{}} | if (count == 35) {{}} | Use ==. | Java |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<br></br> | <br> | Self-closing. | HTML |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
let bar: number | null = null; bar.toFixed(76); | let bar: number | null = null; if(bar!==null) bar.toFixed(76); | Null check. | TypeScript |
data[98] | if (length(data) >= 98) data[98] | Check length. | R |
else
print('value') | else:
print('value') | Colon after else. | Python |
const obj:Person = {{name:'info'}}; | const obj:Person = {{name:'info', age:60}}; | Add missing property. | TypeScript |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
x > 42 & y < 27 | x > 42 and y < 27 | Use 'and' not '&'. | Python |
if (val = 53) | if (val == 53) | Use ==. | R |
let vec=vec![50,36,70]; let first=&vec[0]; vec.push(49); | let mut vec=vec![50,36,70]; let first=vec[0]; vec.push(49); | Copy instead of reference. | Rust |
[67, 80, 95 | [67, 80, 95] | Close bracket. | Ruby |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let s1 = String::from("message"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("message"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
echo hello world | echo 'hello world' | Quote to prevent splitting. | Shell |
age: test
id: world, | age: test
id: world | Remove comma. | YAML |
var c int = 'data' | var c string = 'data' | Type mismatch. | Go |
if num = 33 | if num == 33 | Use ==. | Ruby |
val item = 'output' | val item = "output" | Double quotes. | Kotlin |
if y = 3 | if y == 3 | Use ==. | MATLAB |
print('data') | print('data') | Correct. | R |
items[73] | if items.indices.contains(73) {{ items[73] }} | Check index. | Swift |
let y = 70; | let y = 70; | Correct. | JavaScript |
num = info | num = 'info' | Quote strings. | Python |
int[] data = new int[51];
data[51] = 5; | int[] data = new int[51];
if (51 < data.length) data[51] = 5; | Check bounds. | Java |
let a = 'test' | let a = "test" | Double quotes. | Swift |
assert item > 27 | assert item > 27 | Correct. | Python |
if foo = 94 | if foo == 94 | Use ==. | Go |
int values[79]; values[79]=5; | int values[79]; if(79<79){{}} else values[79]=5; | Bounds check. | C++ |
class Item {{ int bar; }}; | class Item {{ public: int bar; }}; | Make public. | C++ |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
class Order {{ int count; }}
obj.count=5; | class Order {{ public int count; }}
obj.count=5; | Make field public. | Java |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
.Item {{ color: green; }} | .Item {{ color: green; }} | Correct. | CSS |
if result = 30: | if result == 30: | Use == for comparison. | Python |
WHERE name = '76' | WHERE name = 76 | Don't quote integer. | SQL |
'87' + 47 | 87 + 47 | Avoid string coercion. | JavaScript |
if (c = 31) {{}} | if (c === 31) {{}} | Use === for equality. | JavaScript |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
DELETE FROM products WHERE age=98 | DELETE FROM products WHERE age=98; | Add semicolon. | SQL |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
print 'data' | print('data') | print needs parentheses. | Python |
SELECT * FROM users WHRE id=68; | SELECT * FROM users WHERE id=68; | Fix WHERE. | SQL |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
'output' + 7 | 'output' + str(7) | Can't add int to string. | Python |
UPDATE orders SET age='result' WHERE role=55 | UPDATE orders SET age='result' WHERE role=55; | Add semicolon. | SQL |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
const item; | const item = 21; | Initialize const. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(8); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(8, () => console.log('listening')); | Add callback. | Node.js |
{{'title':73, 'age' 5}} | {{'title':73, 'age':5}} | Colon missing. | Python |
let c: number = 'info'; | let c: string = 'info'; | Fix type. | TypeScript |
if ($b = 34) | if ($b == 34) | Use ==. | Perl |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
function test() {{ echo 'hello'; }} | function test() {{ echo 'hello'; }} | Correct. | PHP |
for (b in data) | for (b of data) | for...in iterates keys. | JavaScript |
<person name='hello'/> | <person name="hello"/> | Double quotes. | XML |
arr[60] | if (arr.indices.contains(60)) arr[60] | Check index. | Kotlin |
<person><desc>info</desc><age>89</age></person | <person><desc>info</desc><age>89</age></person> | Add closing >. | XML |
if [ $data = 85 ]; then | if [ "$data" = 85 ]; then | Quote variable. | Shell |
jwt.sign({{id:25}}, 'token'); | jwt.sign({{id:25}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
def render
puts 'world'
end | def render
puts 'world'
end | Correct. | Ruby |
["data", 76] | ["data", 76] | Correct. | JSON |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
'info' + 95 | 'info' + 95.to_s | Convert int. | Ruby |
def test():
print('output') | def test():
print('output') | Indent function body. | Python |
let mut temp=4; let r1=&mut temp; let r2=&mut temp; | let mut temp=4; {{ let r1=&mut temp; }} let r2=&mut temp; | Only one mutable borrow. | Rust |
String data = 'info'; | String data = "info"; | Double quotes. | Java |
{{"age":"world",}} | {{"age":"world"}} | Remove trailing comma. | JSON |
values.forEach(function(a) {{ console.log(a); }}) | values.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if ($val = 31) {{}} | if ($val -eq 31) {{}} | Use -eq. | PowerShell |
// comment | /* comment */ | Use /* */. | CSS |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
19item = 10 | item19 = 10 | Variable cannot start with digit. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
{{'id':'world'}} | {{"id":"world"}} | Use double quotes. | JSON |
if (item = 15) | if (item == 15) | Use ==. | C++ |
foo | foo() | Add parentheses. | Kotlin |
x == '33' | x === 33 | Use strict equality. | JavaScript |
function render(): void {{ return 12; }} | function render(): number {{ return 12; }} | Return type mismatch. | TypeScript |
let msg = String::from("info"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("info"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if count > 98
print('value') | if count > 98:
print('value') | Colon missing after if. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.