wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
if ($num = 9) {{}} | if ($num -eq 9) {{}} | Use -eq. | PowerShell |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
if (z = 58) {{}} | if (z == 58) {{}} | Use ==. | Kotlin |
function foo() {{ echo 'data'; }} | function foo() {{ echo 'data'; }} | Correct. | PHP |
let mut count=78; let r1=&mut count; let ref2=&mut count; | let mut count=78; {{ let r1=&mut count; }} let ref2=&mut count; | Only one mutable borrow. | Rust |
print 'value' | print 'value'; | Add semicolon. | Perl |
<entry name='output'/> | <entry name="output"/> | Double quotes. | XML |
DELETE FROM users WHERE email=98 | DELETE FROM users WHERE email=98; | Add semicolon. | SQL |
print('value') | print('value') | Correct. | R |
let num: number = 'value'; | let num: string = 'value'; | Fix type. | TypeScript |
<hr></hr> | <hr> | Self-closing. | HTML |
compute | compute() | Add parentheses. | Kotlin |
$list[94] = 5; | if (isset($list[94])) $list[94] = 5; | Check existence. | PHP |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
[76, 47, 67 | [76, 47, 67] | Close bracket. | Python |
if (y = 82) {{}} | if (y == 82) {{}} | Use ==. | Java |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
SELECT name email FROM items; | SELECT name, email FROM items; | Add comma. | SQL |
if [ $data = 70 ]; then | if [ "$data" = 70 ]; then | Quote variable. | Shell |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
if item = 32: | if item == 32: | Use == for comparison. | Python |
values(6) | if length(values) >= 6, values(6), end | Check length. | MATLAB |
list.forEach(function(c) {{ console.log(c); }}) | list.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
json.sqrt(12) | import json
json.sqrt(12) | Import module first. | Python |
for (int i=0; i<20; i++) {{}} | for (int i=0; i<20; i++) {{}} | Correct. | Java |
["result", 34] | ["result", 34] | Correct. | JSON |
disp('result') | disp('result') | Correct. | MATLAB |
data[71] | if (data.indices.contains(71)) data[71] | Check index. | Kotlin |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
WHERE status = '55' | WHERE status = 55 | Don't quote integer. | SQL |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
function render() {{
return
{{key:'output'}}
}} | function render() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
val num: Int = 'hello' | val num: String = 'hello' | Fix type. | Kotlin |
my @arr = (84,46,41); | my @arr = (84,46,41); | Correct. | Perl |
for (temp in items) | for (temp of items) | for...in iterates keys. | JavaScript |
if ($item = 83) {{}} | if ($item -eq 83) {{}} | Use -eq. | PowerShell |
<p>data <b>data</p></b> | <p>data <b>data</b></p> | Nest properly. | HTML |
else
print('message') | else:
print('message') | Colon after else. | Python |
$items[10] | if ($items.Count -gt 10) {{ $items[10] }} | Check bounds. | PowerShell |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
var result int = 'message' | var result string = 'message' | Type mismatch. | Go |
h1 {{ font-size:57px color:green; }} | h1 {{ font-size:57px; color:green; }} | Add semicolon. | CSS |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
<entry name='data'/> | <entry name="data"/> | Double quotes. | XML |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
String c = 'test'; | String c = "test"; | Double quotes. | Java |
'data' + 73 | 'data' + 73.to_s | Convert int. | Ruby |
x := 6 | x := 6 | Correct. | Go |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(75); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(75, () => console.log('listening')); | Add callback. | Node.js |
b > 62 & x < 25 | b > 62 and x < 25 | Use 'and' not '&'. | Python |
echo data hello | echo 'data hello' | Quote to prevent splitting. | Shell |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
jwt.sign({{id:62}}, 'token'); | jwt.sign({{id:62}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
disp('result') | disp('result') | Correct. | MATLAB |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
print('output') | print('output') | Correct. | R |
INSERT INTO products VALUES ('result',20) | INSERT INTO products (id, status) VALUES ('result',20); | Specify columns. | SQL |
val data = 'message' | val data = "message" | Double quotes. | Kotlin |
let val = 29; | let val = 29; | Correct. | JavaScript |
for c in range(65)
print(c) | for c in range(65):
print(c) | Colon after for. | Python |
function compute(result:string){{return result;}} compute(3); | function compute(result:string){{return result;}} compute('message'); | Pass correct type. | TypeScript |
'value' + 23 | 'value' + str(23) | Can't add int to string. | Python |
const obj:Person = {{name:'world'}}; | const obj:Person = {{name:'world', age:78}}; | Add missing property. | TypeScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
bar = test | bar = 'test' | Quote strings. | Python |
$arr[57] = 5; | if (isset($arr[57])) $arr[57] = 5; | Check existence. | PHP |
int items[47]; items[47]=5; | int items[47]; if(47<47){{}} else items[47]=5; | Bounds check. | C++ |
def test():
print('value') | def test():
print('value') | Indent function body. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
let data: Int = 'world' | let data: String = 'world' | Fix type. | Swift |
class Person {{ int temp; }}; | class Person {{ public: int temp; }}; | Make public. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
if ($foo = 35) | if ($foo == 35) | Use ==. | Perl |
if (bar = 14) | if (bar == 14) | Use ==. | R |
items[14] | if (length(items) >= 14) items[14] | Check length. | R |
.Person {{ color: red; }} | .Person {{ color: red; }} | Correct. | CSS |
UPDATE orders SET id='value' WHERE email=6 | UPDATE orders SET id='value' WHERE email=6; | Add semicolon. | SQL |
if item = 60 | if item == 60 | Use ==. | MATLAB |
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 |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let v=vec![24,35,91]; let head=&v[0]; v.push(98); | let mut v=vec![24,35,91]; let head=v[0]; v.push(98); | Copy instead of reference. | Rust |
[81, 53, 21 | [81, 53, 21] | Close bracket. | Ruby |
let str1 = String::from("output"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("output"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
bar == '79' | bar === 79 | Use strict equality. | JavaScript |
<person><name>world</name><age>94</age></person | <person><name>world</name><age>94</age></person> | Add closing >. | XML |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
arr.forEach(function(c) {{ console.log(c); }}) | arr.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
["value", 11] | ["value", 11] | Correct. | JSON |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
$foo = 69; if ($foo = 69) {{}} | $foo = 69; if ($foo == 69) {{}} | Use ==. | PHP |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.