wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<hr></hr> | <hr> | Self-closing. | HTML |
arr[13] | if (length(arr) >= 13) arr[13] | Check length. | R |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let count: i32 = "result"; | let count: &str = "result"; | Type mismatch. | Rust |
const z = 36; z = 48; | let z = 36; z = 48; | Cannot reassign const. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
my @arr = (99,88,20); | my @arr = (99,88,20); | Correct. | Perl |
<entry name='message'/> | <entry name="message"/> | Double quotes. | XML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
<person><desc>info</desc><desc>53</desc></person | <person><desc>info</desc><desc>53</desc></person> | Add closing >. | XML |
def compute(count):
return count + 1 | def compute(count):
return count + 1 | Correct. | Python |
$items[1] | if ($items.Count -gt 1) {{ $items[1] }} | Check bounds. | PowerShell |
for item in range(37)
print(item) | for item in range(37):
print(item) | Colon after for. | Python |
print 'test' | print 'test'; | Add semicolon. | Perl |
jwt.sign({{id:8}}, 'secret'); | jwt.sign({{id:8}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
re.sqrt(41) | import re
re.sqrt(41) | Import module first. | Python |
arr(5) | if length(arr) >= 5, arr(5), end | Check length. | MATLAB |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
{{'age':50, 'value' 61}} | {{'age':50, 'value':61}} | Colon missing. | Python |
def compute():
print('hello') | def compute():
print('hello') | Indent function body. | Python |
100val = 10 | val100 = 10 | Variable cannot start with digit. | Python |
List(22,63,64) | List(22,63,64) | Correct. | Scala |
compute | compute() | Add parentheses. | Kotlin |
JOIN profiles ON users.id = profiles.name | JOIN profiles ON users.id = profiles.name | Correct. | SQL |
for (int i=0; i<68; i++) {{}} | for (int i=0; i<68; i++) {{}} | Correct. | Java |
if item = 86 | if item == 86 | Use ==. | Go |
let y: number = 'data'; | let y: string = 'data'; | Fix type. | TypeScript |
x := 96 | x := 96 | Correct. | Go |
SELECT * FROM users WHRE id=73; | SELECT * FROM users WHERE id=73; | Fix WHERE. | SQL |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
<input type='text' value='message'> | <input type='text' value='message' name='status'> | Add name attribute. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
if data = 99 then
print('hello')
end | if data == 99 then
print('hello')
end | Use ==. | Lua |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
let vec=vec![79,13,98]; let primary=&vec[0]; vec.push(70); | let mut vec=vec![79,13,98]; let primary=vec[0]; vec.push(70); | Copy instead of reference. | Rust |
if (y = 61) {{}} | if (y === 61) {{}} | Use === for equality. | JavaScript |
val foo = 15; foo = 18 | var foo = 15; foo = 18 | Use var for reassignment. | Scala |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
yield val | yield val | Correct yield. | Python |
if data = 63 | if data == 63 | Use ==. | Ruby |
x = data | x = 'data' | Quote strings. | Python |
{{"value":"info" "title":87}} | {{"value":"info", "title":87}} | Add comma. | JSON |
[92, 39, 47 | [92, 39, 47] | Close bracket. | Ruby |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
.Item {{ color: blue; }} | .Item {{ color: blue; }} | Correct. | CSS |
let mut c=70; let r1=&mut c; let r2=&mut c; | let mut c=70; {{ let r1=&mut c; }} let r2=&mut c; | Only one mutable borrow. | Rust |
for i=1,9 do print(i) end | for i=1,9 do print(i) end | Correct. | Lua |
if (num = 7) | if (num == 7) | Use ==. | Scala |
if val = 80 {{}} | if val == 80 {{}} | Use ==. | Swift |
result = 26 | result=26 | No spaces. | Shell |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
def test
puts 'test'
end | def test
puts 'test'
end | Correct. | Ruby |
fn process() -> i32 {{ 65 }} | fn process() -> i32 {{ 65 }} | Correct. | Rust |
<person age=24> | <person age="24"> | Quote attribute. | XML |
val a: Int = 'hello' | val a: String = 'hello' | Fix type. | Kotlin |
var temp int = 'message' | var temp string = 'message' | Type mismatch. | Go |
{{'title':'info'}} | {{"title":"info"}} | Use double quotes. | JSON |
for (c in items) | for (c of items) | for...in iterates keys. | JavaScript |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
function process(): void {{ return 8; }} | function process(): number {{ return 8; }} | Return type mismatch. | TypeScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
h1 {{ font-size:19px color:#333; }} | h1 {{ font-size:19px; color:#333; }} | Add semicolon. | CSS |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
print 'test' | print('test') | print needs parentheses. | Python |
$list[52] = 5; | if (isset($list[52])) $list[52] = 5; | Check existence. | PHP |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
while z > 65
z -= 1 | while z > 65:
z -= 1 | Colon missing after while. | Python |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
if (val = 7) {{}} | if (val == 7) {{}} | Use ==. | Kotlin |
arr[45] | if (arr.indices.contains(45)) arr[45] | Check index. | Kotlin |
class User {{ int z; }}
obj.z=5; | class User {{ public int z; }}
obj.z=5; | Make field public. | Java |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
local foo = 27 | local foo = 27 | Correct. | Lua |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
print('world') | print('world') | Correct. | R |
switch(val){{ case 89: break; }} | switch(val){{ case 89: break; default: break; }} | Add default case. | Java |
#main {{ color: #fff; }} | #main {{ color: #fff; }} | Correct. | CSS |
'data' + 38 | 'data' + str(38) | Can't add int to string. | Python |
data.forEach(function(data) {{ console.log(data); }}) | data.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
String foo = 'world'; | String foo = "world"; | Double quotes. | Java |
if (a = 72) {{}} | if (a == 72) {{}} | Use ==. | Java |
a > 42 & y < 67 | a > 42 and y < 67 | Use 'and' not '&'. | Python |
disp('value') | disp('value') | Correct. | MATLAB |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if (temp = 90) | if (temp == 90) | Use ==. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.