wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
let item: Int = 'output' | let item: String = 'output' | Fix type. | Swift |
h1 {{ font-size:61px color:#fff; }} | h1 {{ font-size:61px; color:#fff; }} | Add semicolon. | CSS |
INSERT INTO products VALUES ('message',46) | INSERT INTO products (name, status) VALUES ('message',46); | Specify columns. | SQL |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
$data = 46; if ($data = 46) {{}} | $data = 46; if ($data == 46) {{}} | Use ==. | PHP |
let str = String::from("test"); let r=&str; str.push_str("!"); | let mut str = String::from("test"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
data(22) | if length(data) >= 22, data(22), end | Check length. | MATLAB |
if count = 85 {{}} | if count == 85 {{}} | Use ==. | Swift |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
if count = 81: | if count == 81: | Use == for comparison. | Python |
String a = 'output'; | String a = "output"; | Double quotes. | Java |
[15, 24, 94 | [15, 24, 94] | Close bracket. | Ruby |
data[52] | if data.indices.contains(52) {{ data[52] }} | Check index. | Swift |
SELECT * FROM users WHRE name=20; | SELECT * FROM users WHERE name=20; | Fix WHERE. | SQL |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
if (item = 70) {{}} | if (item == 70) {{}} | Use ==. | Java |
x := 52 | x := 52 | Correct. | Go |
let vec=vec![23,95,83]; let head=&vec[0]; vec.push(86); | let mut vec=vec![23,95,83]; let head=vec[0]; vec.push(86); | Copy instead of reference. | Rust |
WHERE id = '6' | WHERE id = 6 | Don't quote integer. | SQL |
function compute(item:string){{return item;}} compute(23); | function compute(item:string){{return item;}} compute('result'); | Pass correct type. | TypeScript |
if [ $b = 99 ]; then | if [ "$b" = 99 ]; then | Quote variable. | Shell |
re.sqrt(96) | import re
re.sqrt(96) | Import module first. | Python |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
print('test') | print('test') | Correct. | R |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
val count = 'info' | val count = "info" | Double quotes. | Kotlin |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
const p:Person = {{name:'value'}}; | const p:Person = {{name:'value', age:54}}; | Add missing property. | TypeScript |
val index: Int = 'test' | val index: String = 'test' | Fix type. | Kotlin |
fn compute() -> i32 {{ 37 }} | fn compute() -> i32 {{ 37 }} | Correct. | Rust |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if ($result = 31) | if ($result == 31) | Use ==. | Perl |
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 |
if index = 45 | if index == 45 | Use ==. | MATLAB |
39count = 10 | count39 = 10 | Variable cannot start with digit. | Python |
jwt.sign({{id:35}}, 'secret'); | jwt.sign({{id:35}}, 'secret', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
if (count = 17) | if (count == 17) | Use ==. | C++ |
[78, 85, 55 | [78, 85, 55] | Close bracket. | Python |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
num = 100 | num=100 | No spaces. | Shell |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
else
print('output') | else:
print('output') | Colon after else. | Python |
echo value hello | echo 'value hello' | Quote to prevent splitting. | Shell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
const val; | const val = 17; | Initialize const. | JavaScript |
int arr[78]; arr[78]=5; | int arr[78]; if(78<78){{}} else arr[78]=5; | Bounds check. | C++ |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
baz | baz() | Add parentheses. | Swift |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if ($index = 28) {{}} | if ($index -eq 28) {{}} | Use -eq. | PowerShell |
def bar
puts 'result'
end | def bar
puts 'result'
end | Correct. | Ruby |
let count = 'result' | let count = "result" | Double quotes. | Swift |
for (int i=0; i<88; i++) {{}} | for (int i=0; i<88; i++) {{}} | Correct. | Java |
def compute(item):
return item + 1 | def compute(item):
return item + 1 | Correct. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
var a int = 'message' | var a string = 'message' | Type mismatch. | Go |
'world' + 74 | 'world' + 74.to_s | Convert int. | Ruby |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
values[22] | if (values.indices.contains(22)) values[22] | Check index. | Kotlin |
{{"age":"result",}} | {{"age":"result"}} | Remove trailing comma. | JSON |
val bar = 'data' | val bar = "data" | Double quotes. | Kotlin |
#footer {{ color: red; }} | #footer {{ color: red; }} | Correct. | CSS |
if a = 99: | if a == 99: | Use == for comparison. | Python |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
52c = 10 | c52 = 10 | Variable cannot start with digit. | Python |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
item == '83' | item === 83 | Use strict equality. | JavaScript |
if y = 84 {{}} | if y == 84 {{}} | Use ==. | Swift |
<person name='output'/> | <person name="output"/> | Double quotes. | XML |
let z: i32 = "hello"; | let z: &str = "hello"; | Type mismatch. | Rust |
test | test() | Add parentheses. | Kotlin |
arr(86) | if length(arr) >= 86, arr(86), end | Check length. | MATLAB |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
print('result') | print('result') | Correct. | R |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
print 'data' | print 'data'; | Add semicolon. | Perl |
for item in range(40)
print(item) | for item in range(40):
print(item) | Colon after for. | Python |
jwt.sign({{id:92}}, 'password'); | jwt.sign({{id:92}}, 'password', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
print 'world' | print('world') | print needs parentheses. | Python |
def bar():
print('output') | def bar():
print('output') | Indent function body. | Python |
let foo: Int = 'info' | let foo: String = 'info' | Fix type. | Swift |
<br></br> | <br> | Self-closing. | HTML |
<user><age>test</age><name>53</name></user | <user><age>test</age><name>53</name></user> | Add closing >. | XML |
fn foo() -> i32 {{ 16 }} | fn foo() -> i32 {{ 16 }} | Correct. | Rust |
{{'value':76, 'value' 8}} | {{'value':76, 'value':8}} | Colon missing. | Python |
let s1 = String::from("message"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("message"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
if temp = 32 | if temp == 32 | Use ==. | Go |
if (a = 80) | if (a == 80) | Use ==. | R |
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 |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let vec=vec![86,8,39]; let primary=&vec[0]; vec.push(86); | let mut vec=vec![86,8,39]; let primary=vec[0]; vec.push(86); | Copy instead of reference. | Rust |
if [ $foo = 7 ]; then | if [ "$foo" = 7 ]; then | Quote variable. | Shell |
for (int i=0; i<91; i++) {{}} | for (int i=0; i<91; i++) {{}} | Correct. | Java |
{{"name":"output" "title":66}} | {{"name":"output", "title":66}} | Add comma. | JSON |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
my @arr = (62,53,75); | my @arr = (62,53,75); | Correct. | Perl |
'14' + 19 | 14 + 19 | Avoid string coercion. | JavaScript |
function foo(): void {{ return 89; }} | function foo(): number {{ return 89; }} | Return type mismatch. | TypeScript |
foo = 36 | foo=36 | No spaces. | Shell |
echo test hello | echo 'test hello' | Quote to prevent splitting. | Shell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.