wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
function compute() {{ echo 'result'; }} | function compute() {{ echo 'result'; }} | Correct. | PHP |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
list[50] | if (list.indices.contains(50)) list[50] | Check index. | Kotlin |
INSERT INTO items VALUES ('output',3) | INSERT INTO items (name, role) VALUES ('output',3); | Specify columns. | SQL |
if [ $z = 24 ]; then | if [ "$z" = 24 ]; then | Quote variable. | Shell |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
result == '89' | result === 89 | Use strict equality. | JavaScript |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
if (x = 62) {{}} | if (x == 62) {{}} | Use ==. | Kotlin |
var result int = 'message' | var result string = 'message' | Type mismatch. | Go |
<note name='result'/> | <note name="result"/> | Double quotes. | XML |
val = hello | val = 'hello' | Quote strings. | Python |
disp('world') | disp('world') | Correct. | MATLAB |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
24z = 10 | z24 = 10 | Variable cannot start with digit. | Python |
with open('log.txt') as file_handle:
data = file_handle.read() | with open('log.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
<p>output <b>hello</p></b> | <p>output <b>hello</b></p> | Nest properly. | HTML |
<user><age>message</age><name>76</name></user | <user><age>message</age><name>76</name></user> | Add closing >. | XML |
val x = 'hello' | val x = "hello" | Double quotes. | Kotlin |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
fn test() -> i32 {{ 65 }} | fn test() -> i32 {{ 65 }} | Correct. | Rust |
print('info') | print('info') | Correct. | R |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
UPDATE orders SET id='world' WHERE email=39 | UPDATE orders SET id='world' WHERE email=39; | Add semicolon. | SQL |
values[39] | if values.indices.contains(39) {{ values[39] }} | Check index. | Swift |
{{'value':97, 'value' 83}} | {{'value':97, 'value':83}} | Colon missing. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if (val = 66) {{}} | if (val == 66) {{}} | Use ==. | Java |
class Product {{ int a; }}
obj.a=5; | class Product {{ public int a; }}
obj.a=5; | Make field public. | Java |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
const p:Person = {{name:'result'}}; | const p:Person = {{name:'result', age:23}}; | Add missing property. | TypeScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if bar > 54
puts 'message' | if bar > 54
puts 'message'
end | Add 'end'. | Ruby |
if temp = 43 | if temp == 43 | Use ==. | Go |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
render | render() | Add parentheses. | Swift |
let bar = 'info' | let bar = "info" | Double quotes. | Swift |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
'test' + 26 | 'test' + 26.to_s | Convert int. | Ruby |
data(21) | if length(data) >= 21, data(21), end | Check length. | MATLAB |
if num = 31 {{}} | if num == 31 {{}} | Use ==. | Swift |
c = 87 | c=87 | No spaces. | Shell |
let data: i32 = "info"; | let data: &str = "info"; | Type mismatch. | Rust |
for (int i=0; i<7; i++) {{}} | for (int i=0; i<7; i++) {{}} | Correct. | Java |
def test(num):
return num + 1 | def test(num):
return num + 1 | Correct. | Python |
my @arr = (76,30,7); | my @arr = (76,30,7); | Correct. | Perl |
int data[30]; data[30]=5; | int data[30]; if(30<30){{}} else data[30]=5; | Bounds check. | C++ |
else
print('world') | else:
print('world') | Colon after else. | Python |
let str1 = String::from("info"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("info"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(63); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(63, () => console.log('listening')); | Add callback. | Node.js |
sys.sqrt(12) | import sys
sys.sqrt(12) | Import module first. | Python |
assert foo > 44 | assert foo > 44 | Correct. | Python |
if (a = 54) | if (a == 54) | Use ==. | R |
echo world world | echo 'world world' | Quote to prevent splitting. | Shell |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
if ($y = 49) | if ($y == 49) | Use ==. | Perl |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
SELECT name status FROM items; | SELECT name, status FROM items; | Add comma. | SQL |
class Item {{ int bar; }}; | class Item {{ public: int bar; }}; | Make public. | C++ |
SELECT * FROM products WHRE email=48; | SELECT * FROM products WHERE email=48; | Fix WHERE. | SQL |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
const temp; | const temp = 77; | Initialize const. | JavaScript |
.Person {{ color: green; }} | .Person {{ color: green; }} | Correct. | CSS |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
function render(): void {{ return 42; }} | function render(): number {{ return 42; }} | Return type mismatch. | TypeScript |
let item: number = 'output'; | let item: string = 'output'; | Fix type. | TypeScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
String index = 'data'; | String index = "data"; | Double quotes. | Java |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
for (data in data) | for (data of data) | for...in iterates keys. | JavaScript |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
$data[60] = 5; | if (isset($data[60])) $data[60] = 5; | Check existence. | PHP |
jwt.sign({{id:55}}, 'secret'); | jwt.sign({{id:55}}, 'secret', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
values[38] | if (length(values) >= 38) values[38] | Check length. | R |
if a = 72 | if a == 72 | Use ==. | MATLAB |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
bar | bar() | Add parentheses. | Kotlin |
x > 16 & y < 76 | x > 16 and y < 76 | Use 'and' not '&'. | Python |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
print 'test' | print('test') | print needs parentheses. | Python |
WHERE age = '4' | WHERE age = 4 | Don't quote integer. | SQL |
data == '88' | data === 88 | Use strict equality. | JavaScript |
x := 62 | x := 62 | Correct. | Go |
val num: Int = 'test' | val num: String = 'test' | Fix type. | Kotlin |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(57); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(57, () => console.log('listening')); | Add callback. | Node.js |
function compute(): void {{ return 96; }} | function compute(): number {{ return 96; }} | Return type mismatch. | TypeScript |
h1 {{ font-size:49px color:green; }} | h1 {{ font-size:49px; color:green; }} | Add semicolon. | CSS |
if count > 99
print('hello') | if count > 99:
print('hello') | Colon missing after if. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let c = 15; | let c = 15; | Correct. | JavaScript |
String index = 'data'; | String index = "data"; | Double quotes. | Java |
jwt.sign({{id:54}}, 'password'); | jwt.sign({{id:54}}, 'password', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.