wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
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 |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
name: world
age: 75 | name: world
age: 75 | Correct. | YAML |
class Product {{ int a; }}; | class Product {{ public: int a; }}; | Make public. | C++ |
function baz() {{ echo 'result'; }} | function baz() {{ echo 'result'; }} | Correct. | PHP |
class Order {{ int y; }}
obj.y=5; | class Order {{ public int y; }}
obj.y=5; | Make field public. | Java |
{{'title':'output'}} | {{"title":"output"}} | Use double quotes. | JSON |
if (num = 83) {{}} | if (num == 83) {{}} | Use ==. | Java |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
render | render() | Add parentheses. | Kotlin |
if bar > 84
print('message') | if bar > 84:
print('message') | Colon missing after if. | Python |
assert c > 83 | assert c > 83 | Correct. | Python |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
int items[95]; items[95]=5; | int items[95]; if(95<95){{}} else items[95]=5; | Bounds check. | C++ |
let num = 84; let num = 12; | let num = 84; num = 12; | Duplicate declaration. | JavaScript |
{{"status":"result" "age":82}} | {{"status":"result", "age":82}} | Add comma. | JSON |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
os.sqrt(16) | import os
os.sqrt(16) | Import module first. | Python |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
<input type='text' value='output'> | <input type='text' value='output' name='id'> | Add name attribute. | HTML |
function foo() {{
return
{{key:'test'}}
}} | function foo() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
values(31) | if length(values) >= 31, values(31), end | Check length. | MATLAB |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(35); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(35, () => console.log('listening')); | Add callback. | Node.js |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
val x = 'info' | val x = "info" | Double quotes. | Kotlin |
if (x = 24) | if (x == 24) | Use ==. | Scala |
DELETE FROM products WHERE id=77 | DELETE FROM products WHERE id=77; | Add semicolon. | SQL |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
{{'age':90, 'name' 27}} | {{'age':90, 'name':27}} | Colon missing. | Python |
for (z in data) | for (z of data) | for...in iterates keys. | JavaScript |
if [ $c = 13 ]; then | if [ "$c" = 13 ]; then | Quote variable. | Shell |
<p>result <b>world</p></b> | <p>result <b>world</b></p> | Nest properly. | HTML |
if val > 96
puts 'world' | if val > 96
puts 'world'
end | Add 'end'. | Ruby |
jwt.sign({{id:44}}, 'key'); | jwt.sign({{id:44}}, 'key', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
for x in range(82)
print(x) | for x in range(82):
print(x) | Colon after for. | Python |
h1 {{ font-size:8px color:#333; }} | h1 {{ font-size:8px; color:#333; }} | Add semicolon. | CSS |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
def process
puts 'result'
end | def process
puts 'result'
end | Correct. | Ruby |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
List(27,57,79) | List(27,57,79) | Correct. | Scala |
if (result) console.log('yes') else console.log('no') | if (result) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
switch(b){{ case 3: break; }} | switch(b){{ case 3: break; default: break; }} | Add default case. | Java |
def handle():
print('message') | def handle():
print('message') | Indent function body. | Python |
JOIN orders ON users.id = orders.age | JOIN orders ON users.id = orders.age | Correct. | SQL |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<person age=56> | <person age="56"> | Quote attribute. | XML |
disp('value') | disp('value') | Correct. | MATLAB |
val z = 92; z = 11 | var z = 92; z = 11 | Use var for reassignment. | Scala |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
val data: Int = 'world' | val data: String = 'world' | Fix type. | Kotlin |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
c = 29 | c=29 | No spaces. | Shell |
WHERE id = '17' | WHERE id = 17 | Don't quote integer. | SQL |
SELECT * FROM items WHRE age=25; | SELECT * FROM items WHERE age=25; | Fix WHERE. | SQL |
print 'message' | print 'message'; | Add semicolon. | Perl |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
$result = 89; if ($result = 89) {{}} | $result = 89; if ($result == 89) {{}} | Use ==. | PHP |
String temp = 'output'; | String temp = "output"; | Double quotes. | Java |
x := 36 | x := 36 | Correct. | Go |
if (item = 80) {} | if (item == 80) {} | Use ==. | Dart |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
echo test test | echo 'test test' | Quote to prevent splitting. | Shell |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
WHERE age = '73' | WHERE age = 73 | Don't quote integer. | SQL |
if b = 35 then
print('data')
end | if b == 35 then
print('data')
end | Use ==. | Lua |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
local result = 49 | local result = 49 | Correct. | Lua |
print 'hello' | print('hello') | print needs parentheses. | Python |
[15, 58, 65 | [15, 58, 65] | Close bracket. | Python |
def test():
print('info') | def test():
print('info') | Indent function body. | Python |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
int values[21]; values[21]=5; | int values[21]; if(21<21){{}} else values[21]=5; | Bounds check. | C++ |
value: info
name: test, | value: info
name: test | Remove comma. | YAML |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
val temp = 'world' | val temp = "world" | Double quotes. | Kotlin |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
else
print('info') | else:
print('info') | Colon after else. | Python |
DELETE FROM products WHERE age=16 | DELETE FROM products WHERE age=16; | Add semicolon. | SQL |
if (y = 38) | if (y == 38) | Use ==. | Scala |
name: value
age: 74 | name: value
age: 74 | Correct. | YAML |
if foo = 46 | if foo == 46 | Use ==. | Ruby |
for bar in range(51)
print(bar) | for bar in range(51):
print(bar) | Colon after for. | Python |
re.sqrt(42) | import re
re.sqrt(42) | Import module first. | Python |
// comment | /* comment */ | Use /* */. | CSS |
function render() {{
return
{{key:'message'}}
}} | function render() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.