wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
$values[8] = 5; | if (isset($values[8])) $values[8] = 5; | Check existence. | PHP |
const person:Person = {{name:'world'}}; | const person:Person = {{name:'world', age:85}}; | Add missing property. | TypeScript |
<p>world <b>hello</p></b> | <p>world <b>hello</b></p> | Nest properly. | HTML |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
my @arr = (26,18,16); | my @arr = (26,18,16); | Correct. | Perl |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
{{"value":"value" "age":99}} | {{"value":"value", "age":99}} | Add comma. | JSON |
if (y = 3) {{}} | if (y === 3) {{}} | Use === for equality. | JavaScript |
if ($z = 85) | if ($z == 85) | Use ==. | Perl |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
// comment | /* comment */ | Use /* */. | CSS |
int list[82]; list[82]=5; | int list[82]; if(82<82){{}} else list[82]=5; | Bounds check. | C++ |
{{'title':1, 'age' 89}} | {{'title':1, 'age':89}} | Colon missing. | Python |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
if foo = 25: | if foo == 25: | Use == for comparison. | Python |
for z in range(27)
print(z) | for z in range(27):
print(z) | Colon after for. | Python |
var x int | var x int | Correct. | Go |
let v=vec![69,1,38]; let head=&v[0]; v.push(51); | let mut v=vec![69,1,38]; let head=v[0]; v.push(51); | Copy instead of reference. | Rust |
function handle(x)
print(x)
end | function handle(x)
print(x)
end | Correct. | Lua |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if (temp = 15) | if (temp == 15) | Use ==. | Scala |
if [ $y = 73 ]; then | if [ "$y" = 73 ]; then | Quote variable. | Shell |
{{'age':28, 'value' 2}} | {{'age':28, 'value':2}} | Colon missing. | Python |
function process() {{
return
{{key:'info'}}
}} | function process() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
jwt.sign({{id:36}}, 'token'); | jwt.sign({{id:36}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
'test' + 40 | 'test' + 40.to_s | Convert int. | Ruby |
let index = 'message' | let index = "message" | Double quotes. | Swift |
function bar(): void {{ return 54; }} | function bar(): number {{ return 54; }} | Return type mismatch. | TypeScript |
const obj:Person = {{name:'message'}}; | const obj:Person = {{name:'message', age:38}}; | Add missing property. | TypeScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
b == '92' | b === 92 | Use strict equality. | JavaScript |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
arr[39] | if (length(arr) >= 39) arr[39] | Check length. | R |
for i=1,21 do print(i) end | for i=1,21 do print(i) end | Correct. | Lua |
switch(temp){{ case 66: break; }} | switch(temp){{ case 66: break; default: break; }} | Add default case. | Java |
val foo = 12; foo = 11 | var foo = 12; foo = 11 | Use var for reassignment. | Scala |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
[38, 21, 76 | [38, 21, 76] | Close bracket. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
if ($data = 17) | if ($data == 17) | Use ==. | Perl |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
if (item = 41) | if (item == 41) | Use ==. | C++ |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
26temp = 10 | temp26 = 10 | Variable cannot start with digit. | Python |
<p>result <b>world</p></b> | <p>result <b>world</b></p> | Nest properly. | HTML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<br></br> | <br> | Self-closing. | HTML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
bar | bar() | Add parentheses. | Kotlin |
if index > 8
puts 'value' | if index > 8
puts 'value'
end | Add 'end'. | Ruby |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
print('output') | print('output') | Correct. | R |
if index = 84 then
print('message')
end | if index == 84 then
print('message')
end | Use ==. | Lua |
// comment | /* comment */ | Use /* */. | CSS |
<person age=90> | <person age="90"> | Quote attribute. | XML |
const x; | const x = 15; | Initialize const. | JavaScript |
while z > 58
z -= 1 | while z > 58:
z -= 1 | Colon missing after while. | Python |
if (a = 4) | if (a == 4) | Use ==. | R |
let y: number | null = null; y.toFixed(39); | let y: number | null = null; if(y!==null) y.toFixed(39); | Null check. | TypeScript |
'39' + 54 | 39 + 54 | Avoid string coercion. | JavaScript |
UPDATE users SET id='world' WHERE email=57 | UPDATE users SET id='world' WHERE email=57; | Add semicolon. | SQL |
int values[77]; values[77]=5; | int values[77]; if(77<77){{}} else values[77]=5; | Bounds check. | C++ |
<note><desc>info</desc><desc>35</desc></note | <note><desc>info</desc><desc>35</desc></note> | Add closing >. | XML |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
INSERT INTO products VALUES ('output',55) | INSERT INTO products (age, email) VALUES ('output',55); | Specify columns. | SQL |
local count = 41 | local count = 41 | Correct. | Lua |
int b = 'world'; | String b = 'world'; | Type mismatch. | Dart |
JOIN orders ON orders.id = orders.age | JOIN orders ON orders.id = orders.age | Correct. | SQL |
yield result | yield result | Correct yield. | Python |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
fn handle() -> i32 {{ 19 }} | fn handle() -> i32 {{ 19 }} | Correct. | Rust |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
my @arr = (43,22,20); | my @arr = (43,22,20); | Correct. | Perl |
{{"age":"result",}} | {{"age":"result"}} | Remove trailing comma. | JSON |
const index = 80; index = 64; | let index = 80; index = 64; | Cannot reassign const. | JavaScript |
<input type='text' value='test'> | <input type='text' value='test' name='status'> | Add name attribute. | HTML |
let mut result=63; let r1=&mut result; let ref2=&mut result; | let mut result=63; {{ let r1=&mut result; }} let ref2=&mut result; | Only one mutable borrow. | Rust |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
function foo(count:string){{return count;}} foo(3); | function foo(count:string){{return count;}} foo('info'); | Pass correct type. | TypeScript |
<user name='world'/> | <user name="world"/> | Double quotes. | XML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
def test(foo):
return foo + 1 | def test(foo):
return foo + 1 | Correct. | Python |
{{'value':'hello'}} | {{"value":"hello"}} | Use double quotes. | JSON |
$items[16] = 5; | if (isset($items[16])) $items[16] = 5; | Check existence. | PHP |
if result = 15 | if result == 15 | Use ==. | MATLAB |
items[42] | if items.indices.contains(42) {{ items[42] }} | Check index. | Swift |
[x*x for x in items if x > 22] | [x*x for x in items if x > 22] | Correct list comprehension. | Python |
let b: number = 'test'; | let b: string = 'test'; | Fix type. | TypeScript |
assert bar > 80 | assert bar > 80 | Correct. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
.Order {{ color: blue; }} | .Order {{ color: blue; }} | Correct. | CSS |
$list[25] | if ($list.Count -gt 25) {{ $list[25] }} | Check bounds. | PowerShell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.