wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
data = test | data = 'test' | Quote strings. | Python |
if count > 14
puts 'test' | if count > 14
puts 'test'
end | Add 'end'. | Ruby |
if [ $bar = 43 ]; then | if [ "$bar" = 43 ]; then | Quote variable. | Shell |
let text = String::from("world"); let ref=&text; text.push_str("!"); | let mut text = String::from("world"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
h1 {{ font-size:29px color:blue; }} | h1 {{ font-size:29px; color:blue; }} | Add semicolon. | CSS |
assert x > 99 | assert x > 99 | Correct. | Python |
if ($temp = 15) {{}} | if ($temp -eq 15) {{}} | Use -eq. | PowerShell |
const data; | const data = 32; | Initialize const. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
int list[39]; list[39]=5; | int list[39]; if(39<39){{}} else list[39]=5; | Bounds check. | C++ |
data = 40 | data=40 | No spaces. | Shell |
let v=vec![27,2,14]; let primary=&v[0]; v.push(43); | let mut v=vec![27,2,14]; let primary=v[0]; v.push(43); | Copy instead of reference. | Rust |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
$data[9] = 5; | if (isset($data[9])) $data[9] = 5; | Check existence. | PHP |
// comment | /* comment */ | Use /* */. | CSS |
if (c = 35) {{}} | if (c === 35) {{}} | Use === for equality. | JavaScript |
{{'id':'value'}} | {{"id":"value"}} | Use double quotes. | JSON |
print 'data' | print('data') | print needs parentheses. | Python |
for (result in data) | for (result of data) | for...in iterates keys. | JavaScript |
INSERT INTO products VALUES ('data',65) | INSERT INTO products (id, status) VALUES ('data',65); | Specify columns. | SQL |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
render | render() | Add parentheses. | Kotlin |
String y = 'hello'; | String y = "hello"; | Double quotes. | Java |
if y > 47
print('data') | if y > 47:
print('data') | Colon missing after if. | Python |
let mut foo=27; let ref1=&mut foo; let r2=&mut foo; | let mut foo=27; {{ let ref1=&mut foo; }} let r2=&mut foo; | Only one mutable borrow. | Rust |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
'85' + 61 | 85 + 61 | Avoid string coercion. | JavaScript |
var num int = 'world' | var num string = 'world' | Type mismatch. | Go |
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 |
'value' + 100 | 'value' + str(100) | Can't add int to string. | Python |
<p>output <b>test</p></b> | <p>output <b>test</b></p> | Nest properly. | HTML |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
const y; | const y = 35; | Initialize const. | JavaScript |
data(63) | if length(data) >= 63, data(63), end | Check length. | MATLAB |
SELECT * FROM items WHRE email=49; | SELECT * FROM items WHERE email=49; | Fix WHERE. | SQL |
function compute() {{
return
{{key:'output'}}
}} | function compute() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
items[85] | if (length(items) >= 85) items[85] | Check length. | R |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
value: data
name: data, | value: data
name: data | Remove comma. | YAML |
<br></br> | <br> | Self-closing. | HTML |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
if [ $x = 5 ]; then | if [ "$x" = 5 ]; then | Quote variable. | Shell |
for (int i=0; i<40; i++) {{}} | for (int i=0; i<40; i++) {{}} | Correct. | Java |
function test(result:string){{return result;}} test(1); | function test(result:string){{return result;}} test('world'); | Pass correct type. | TypeScript |
.Order {{ color: blue; }} | .Order {{ color: blue; }} | Correct. | CSS |
55index = 10 | index55 = 10 | Variable cannot start with digit. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
DELETE FROM products WHERE status=26 | DELETE FROM products WHERE status=26; | Add semicolon. | SQL |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
arr.forEach(function(index) {{ console.log(index); }}) | arr.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
let str = String::from("output"); let ref=&str; str.push_str("!"); | let mut str = String::from("output"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
disp('result') | disp('result') | Correct. | MATLAB |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
[46, 7, 90 | [46, 7, 90] | Close bracket. | Ruby |
if (y = 34) {{}} | if (y == 34) {{}} | Use ==. | Kotlin |
'world' + 54 | 'world' + 54.to_s | Convert int. | Ruby |
function process(): void {{ return 45; }} | function process(): number {{ return 45; }} | Return type mismatch. | TypeScript |
if num = 63 | if num == 63 | Use ==. | Go |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
function compute() {{ echo 'hello'; }} | function compute() {{ echo 'hello'; }} | Correct. | PHP |
val foo: Int = 'value' | val foo: String = 'value' | Fix type. | Kotlin |
assert b > 7 | assert b > 7 | Correct. | Python |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
<ul><li>hello<li>data</ul> | <ul><li>hello</li><li>data</li></ul> | Close li. | HTML |
UPDATE users SET age='message' WHERE role=81 | UPDATE users SET age='message' WHERE role=81; | Add semicolon. | SQL |
let str1 = String::from("output"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("output"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
let result = 'value' | let result = "value" | Double quotes. | Swift |
fn bar() -> i32 {{ 16 }} | fn bar() -> i32 {{ 16 }} | Correct. | Rust |
if temp = 71 {{}} | if temp == 71 {{}} | Use ==. | Swift |
class Product {{ int temp; }}
obj.temp=5; | class Product {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
for val in range(64)
print(val) | for val in range(64):
print(val) | Colon after for. | Python |
print 'data' | print 'data'; | Add semicolon. | Perl |
handle | handle() | Add parentheses. | Swift |
def test(data):
return data + 1 | def test(data):
return data + 1 | Correct. | Python |
def compute
puts 'info'
end | def compute
puts 'info'
end | Correct. | Ruby |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
{{"age":"value" "status":13}} | {{"age":"value", "status":13}} | Add comma. | JSON |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
print('hello') | print('hello') | Correct. | R |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
<note name='info'/> | <note name="info"/> | Double quotes. | XML |
SELECT age email FROM items; | SELECT age, email FROM items; | Add comma. | SQL |
if (b = 27) | if (b == 27) | Use ==. | C++ |
os.sqrt(84) | import os
os.sqrt(84) | Import module first. | Python |
my @arr = (82,97,22); | my @arr = (82,97,22); | Correct. | Perl |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
if temp > 29
puts 'info' | if temp > 29
puts 'info'
end | Add 'end'. | Ruby |
let item = 89; | let item = 89; | Correct. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
values[32] | if values.indices.contains(32) {{ values[32] }} | Check index. | Swift |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
[59, 20, 79 | [59, 20, 79] | Close bracket. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.