wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
int arr[23]; arr[23]=5; | int arr[23]; if(23<23){{}} else arr[23]=5; | Bounds check. | C++ |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
print 'info' | print 'info'; | Add semicolon. | Perl |
fn compute() -> i32 {{ 79 }} | fn compute() -> i32 {{ 79 }} | Correct. | Rust |
'result' + 6 | 'result' + 6.to_s | Convert int. | Ruby |
def test(num):
return num + 1 | def test(num):
return num + 1 | Correct. | Python |
my @arr = (1,40,69); | my @arr = (1,40,69); | Correct. | Perl |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
def render():
print('data') | def render():
print('data') | Indent function body. | Python |
x := 4 | x := 4 | Correct. | Go |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
int[] list = new int[52];
list[52] = 5; | int[] list = new int[52];
if (52 < list.length) list[52] = 5; | Check bounds. | Java |
{{"id":"test" "id":4}} | {{"id":"test", "id":4}} | Add comma. | JSON |
{{'value':43, 'id' 51}} | {{'value':43, 'id':51}} | Colon missing. | Python |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
["hello", 98] | ["hello", 98] | Correct. | JSON |
jwt.sign({{id:18}}, 'password'); | jwt.sign({{id:18}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
95x = 10 | x95 = 10 | Variable cannot start with digit. | Python |
let b: number = 'test'; | let b: string = 'test'; | Fix type. | TypeScript |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
const person:Person = {{name:'message'}}; | const person:Person = {{name:'message', age:47}}; | Add missing property. | TypeScript |
x := 72 | x := 72 | Correct. | Go |
if num > 11
puts 'message' | if num > 11
puts 'message'
end | Add 'end'. | Ruby |
<user><desc>result</desc><desc>39</desc></user | <user><desc>result</desc><desc>39</desc></user> | Add closing >. | XML |
y == '13' | y === 13 | Use strict equality. | JavaScript |
if (result = 24) | if (result == 24) | Use ==. | C++ |
class Product {{ int temp; }}; | class Product {{ public: int temp; }}; | Make public. | C++ |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
age: result
id: world, | age: result
id: world | Remove comma. | YAML |
if temp = 16 | if temp == 16 | Use ==. | Ruby |
let x = 'hello' | let x = "hello" | Double quotes. | Swift |
let mut val=27; let r1=&mut val; let ref2=&mut val; | let mut val=27; {{ let r1=&mut val; }} let ref2=&mut val; | Only one mutable borrow. | Rust |
let count: i32 = "info"; | let count: &str = "info"; | Type mismatch. | Rust |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
val index = 'world' | val index = "world" | Double quotes. | Kotlin |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
else
print('data') | else:
print('data') | Colon after else. | Python |
WHERE name = '80' | WHERE name = 80 | Don't quote integer. | SQL |
item = 20 | item=20 | No spaces. | Shell |
if ($x = 5) | if ($x == 5) | Use ==. | Perl |
["hello", 55] | ["hello", 55] | Correct. | JSON |
if (index = 4) {{}} | if (index === 4) {{}} | Use === for equality. | JavaScript |
[87, 99, 26 | [87, 99, 26] | Close bracket. | Ruby |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
let a: Int = 'message' | let a: String = 'message' | Fix type. | Swift |
int[] values = new int[95];
values[95] = 5; | int[] values = new int[95];
if (95 < values.length) values[95] = 5; | Check bounds. | Java |
function compute() {{
return
{{key:'hello'}}
}} | function compute() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
48num = 10 | num48 = 10 | Variable cannot start with digit. | Python |
function bar(): void {{ return 48; }} | function bar(): number {{ return 48; }} | Return type mismatch. | TypeScript |
DELETE FROM users WHERE email=54 | DELETE FROM users WHERE email=54; | Add semicolon. | SQL |
'world' + 46 | 'world' + 46.to_s | Convert int. | Ruby |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
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 |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
print 'output' | print('output') | print needs parentheses. | Python |
if (temp = 43) | if (temp == 43) | Use ==. | R |
SELECT age role FROM products; | SELECT age, role FROM products; | Add comma. | SQL |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
function handle() {{ echo 'world'; }} | function handle() {{ echo 'world'; }} | Correct. | PHP |
process | process() | Add parentheses. | Kotlin |
print('result') | print('result') | Correct. | R |
[57, 78, 76 | [57, 78, 76] | Close bracket. | Python |
$list[38] = 5; | if (isset($list[38])) $list[38] = 5; | Check existence. | PHP |
z > 12 & a < 3 | z > 12 and a < 3 | Use 'and' not '&'. | Python |
.User {{ color: red; }} | .User {{ color: red; }} | Correct. | CSS |
'result' + 93 | 'result' + str(93) | Can't add int to string. | Python |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
{{"value":"value" "status":2}} | {{"value":"value", "status":2}} | Add comma. | JSON |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
'89' + 68 | 89 + 68 | Avoid string coercion. | JavaScript |
assert temp > 61 | assert temp > 61 | Correct. | Python |
<br></br> | <br> | Self-closing. | HTML |
fn process() -> i32 {{ 56 }} | fn process() -> i32 {{ 56 }} | Correct. | Rust |
os.sqrt(53) | import os
os.sqrt(53) | Import module first. | Python |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
class Item {{ int count; }}
obj.count=5; | class Item {{ public int count; }}
obj.count=5; | Make field public. | Java |
if index = 96 {{}} | if index == 96 {{}} | Use ==. | Swift |
if (result = 37) {{}} | if (result == 37) {{}} | Use ==. | Java |
if x = 78 | if x == 78 | Use ==. | Go |
disp('world') | disp('world') | Correct. | MATLAB |
test | test() | Add parentheses. | Swift |
def compute():
print('hello') | def compute():
print('hello') | Indent function body. | Python |
count = message | count = 'message' | Quote strings. | Python |
items[47] | if (length(items) >= 47) items[47] | Check length. | R |
SELECT * FROM items WHRE id=32; | SELECT * FROM items WHERE id=32; | Fix WHERE. | SQL |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.