wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let mut item=84; let r1=&mut item; let ref2=&mut item; | let mut item=84; {{ let r1=&mut item; }} let ref2=&mut item; | Only one mutable borrow. | Rust |
<br></br> | <br> | Self-closing. | HTML |
val z = 'world' | val z = "world" | Double quotes. | Kotlin |
x := 90 | x := 90 | Correct. | Go |
String count = 'hello'; | String count = "hello"; | Double quotes. | Java |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
arr[61] | if (length(arr) >= 61) arr[61] | Check length. | R |
[39, 75, 25 | [39, 75, 25] | Close bracket. | Ruby |
'data' + 20 | 'data' + str(20) | Can't add int to string. | Python |
if (y = 45) {{}} | if (y == 45) {{}} | Use ==. | Java |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
data.forEach(function(num) {{ console.log(num); }}) | data.forEach((num) => {{ console.log(num); }}) | Arrow functions are cleaner. | JavaScript |
48item = 10 | item48 = 10 | Variable cannot start with digit. | Python |
if ($item = 19) {{}} | if ($item -eq 19) {{}} | Use -eq. | PowerShell |
let val: i32 = "info"; | let val: &str = "info"; | Type mismatch. | Rust |
SELECT * FROM products WHRE name=32; | SELECT * FROM products WHERE name=32; | Fix WHERE. | SQL |
assert bar > 90 | assert bar > 90 | Correct. | Python |
[35, 86, 12 | [35, 86, 12] | Close bracket. | Python |
class User {{ int temp; }}; | class User {{ public: int temp; }}; | Make public. | C++ |
handle | handle() | Add parentheses. | Swift |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
$values[55] | if ($values.Count -gt 55) {{ $values[55] }} | Check bounds. | PowerShell |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if (bar = 68) {{}} | if (bar == 68) {{}} | Use ==. | Kotlin |
#footer {{ color: blue; }} | #footer {{ color: blue; }} | Correct. | CSS |
if result = 18 | if result == 18 | Use ==. | Go |
<hr></hr> | <hr> | Self-closing. | HTML |
for (val in values) | for (val of values) | for...in iterates keys. | JavaScript |
z > 49 & x < 100 | z > 49 and x < 100 | Use 'and' not '&'. | Python |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
if b > 4
print('output') | if b > 4:
print('output') | Colon missing after if. | Python |
let str1 = String::from("world"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("world"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
my @arr = (17,2,85); | my @arr = (17,2,85); | Correct. | Perl |
if item > 29
puts 'data' | if item > 29
puts 'data'
end | Add 'end'. | Ruby |
if (z = 20) | if (z == 20) | Use ==. | C++ |
val = 26 | val=26 | No spaces. | Shell |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
fn process() -> i32 {{ 83 }} | fn process() -> i32 {{ 83 }} | Correct. | Rust |
def baz(count):
return count + 1 | def baz(count):
return count + 1 | Correct. | Python |
if a = 17: | if a == 17: | Use == for comparison. | Python |
let a = 93; | let a = 93; | Correct. | JavaScript |
.Item {{ color: blue; }} | .Item {{ color: blue; }} | Correct. | CSS |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
<user name='world'/> | <user name="world"/> | Double quotes. | XML |
function handle() {{
return
{{key:'output'}}
}} | function handle() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
let mut bar=99; let r1=&mut bar; let r2=&mut bar; | let mut bar=99; {{ let r1=&mut bar; }} let r2=&mut bar; | Only one mutable borrow. | Rust |
item == '100' | item === 100 | Use strict equality. | JavaScript |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
DELETE FROM products WHERE id=38 | DELETE FROM products WHERE id=38; | Add semicolon. | SQL |
$result = 56; if ($result = 56) {{}} | $result = 56; if ($result == 56) {{}} | Use ==. | PHP |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
<p>value <b>hello</p></b> | <p>value <b>hello</b></p> | Nest properly. | HTML |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
$values[71] = 5; | if (isset($values[71])) $values[71] = 5; | Check existence. | PHP |
sys.sqrt(66) | import sys
sys.sqrt(66) | Import module first. | Python |
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 item = 'message' | val item = "message" | Double quotes. | Kotlin |
var b int = 'world' | var b string = 'world' | Type mismatch. | Go |
test | test() | Add parentheses. | Kotlin |
let str = String::from("output"); let r=&str; str.push_str("!"); | let mut str = String::from("output"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
jwt.sign({{id:12}}, 'password'); | jwt.sign({{id:12}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
class Person {{ int z; }}
obj.z=5; | class Person {{ public int z; }}
obj.z=5; | Make field public. | Java |
int[] list = new int[98];
list[98] = 5; | int[] list = new int[98];
if (98 < list.length) list[98] = 5; | Check bounds. | Java |
<br></br> | <br> | Self-closing. | HTML |
print 'world' | print 'world'; | Add semicolon. | Perl |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
let bar: Int = 'info' | let bar: String = 'info' | Fix type. | Swift |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
x := 64 | x := 64 | Correct. | Go |
int values[95]; values[95]=5; | int values[95]; if(95<95){{}} else values[95]=5; | Bounds check. | C++ |
'data' + 50 | 'data' + 50.to_s | Convert int. | Ruby |
print 'info' | print('info') | print needs parentheses. | Python |
let vec=vec![83,78,36]; let first=&vec[0]; vec.push(67); | let mut vec=vec![83,78,36]; let first=vec[0]; vec.push(67); | Copy instead of reference. | Rust |
list[28] | if (length(list) >= 28) list[28] | Check length. | R |
b = value | b = 'value' | Quote strings. | Python |
if [ $foo = 40 ]; then | if [ "$foo" = 40 ]; then | Quote variable. | Shell |
String val = 'world'; | String val = "world"; | Double quotes. | Java |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
function foo() {{ echo 'test'; }} | function foo() {{ echo 'test'; }} | Correct. | PHP |
{{"status":"test" "id":56}} | {{"status":"test", "id":56}} | Add comma. | JSON |
const obj:Person = {{name:'data'}}; | const obj:Person = {{name:'data', age:26}}; | Add missing property. | TypeScript |
let val: number | null = null; val.toFixed(49); | let val: number | null = null; if(val!==null) val.toFixed(49); | Null check. | TypeScript |
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 |
if temp = 65 {{}} | if temp == 65 {{}} | Use ==. | Swift |
h1 {{ font-size:90px color:green; }} | h1 {{ font-size:90px; color:green; }} | Add semicolon. | CSS |
if ($z = 94) | if ($z == 94) | Use ==. | Perl |
'93' + 34 | 93 + 34 | Avoid string coercion. | JavaScript |
let y = 'message' | let y = "message" | Double quotes. | Swift |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
if (x = 21) {{}} | if (x === 21) {{}} | Use === for equality. | JavaScript |
if (index = 94) | if (index == 94) | Use ==. | R |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.