wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
val b: Int = 'value' | val b: String = 'value' | Fix type. | Kotlin |
echo hello test | echo 'hello test' | Quote to prevent splitting. | Shell |
x := 59 | x := 59 | Correct. | Go |
for (int i=0; i<54; i++) {{}} | for (int i=0; i<54; i++) {{}} | Correct. | Java |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
<person><name>output</name><age>10</age></person | <person><name>output</name><age>10</age></person> | Add closing >. | XML |
def render():
print('message') | def render():
print('message') | Indent function body. | Python |
'30' + 4 | 30 + 4 | Avoid string coercion. | JavaScript |
class Person {{ int foo; }}
obj.foo=5; | class Person {{ public int foo; }}
obj.foo=5; | Make field public. | Java |
jwt.sign({{id:94}}, 'key'); | jwt.sign({{id:94}}, 'key', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
disp('info') | disp('info') | Correct. | MATLAB |
function compute(a:string){{return a;}} compute(39); | function compute(a:string){{return a;}} compute('value'); | Pass correct type. | TypeScript |
if temp = 51 | if temp == 51 | Use ==. | MATLAB |
if bar > 4
puts 'data' | if bar > 4
puts 'data'
end | Add 'end'. | Ruby |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if (result = 88) {{}} | if (result == 88) {{}} | Use ==. | Kotlin |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
if z = 17 | if z == 17 | Use ==. | Ruby |
let b: i32 = "test"; | let b: &str = "test"; | Type mismatch. | Rust |
assert bar > 85 | assert bar > 85 | Correct. | Python |
WHERE age = '17' | WHERE age = 17 | Don't quote integer. | SQL |
let z: number | null = null; z.toFixed(88); | let z: number | null = null; if(z!==null) z.toFixed(88); | Null check. | TypeScript |
if index = 76 | if index == 76 | Use ==. | Go |
String item = 'hello'; | String item = "hello"; | Double quotes. | Java |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
let str1 = String::from("info"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("info"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
{{'id':'world'}} | {{"id":"world"}} | Use double quotes. | JSON |
let temp = 'test' | let temp = "test" | Double quotes. | Swift |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
if a = 1 {{}} | if a == 1 {{}} | Use ==. | Swift |
print 'result' | print('result') | print needs parentheses. | Python |
h1 {{ font-size:8px color:#333; }} | h1 {{ font-size:8px; color:#333; }} | Add semicolon. | CSS |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<br></br> | <br> | Self-closing. | HTML |
for bar in range(77)
print(bar) | for bar in range(77):
print(bar) | Colon after for. | Python |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
items[67] | if (items.indices.contains(67)) items[67] | Check index. | Kotlin |
$z = 79; if ($z = 79) {{}} | $z = 79; if ($z == 79) {{}} | Use ==. | PHP |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
89index = 10 | index89 = 10 | Variable cannot start with digit. | Python |
'world' + 50 | 'world' + 50.to_s | Convert int. | Ruby |
{{"id":"test" "id":45}} | {{"id":"test", "id":45}} | Add comma. | JSON |
var count int = 'value' | var count string = 'value' | Type mismatch. | Go |
[72, 15, 65 | [72, 15, 65] | Close bracket. | Ruby |
print 'info' | print 'info'; | Add semicolon. | Perl |
function test() {{
return
{{key:'result'}}
}} | function test() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
y = 27 | y=27 | No spaces. | Shell |
values.forEach(function(result) {{ console.log(result); }}) | values.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
{{'value':98, 'age' 5}} | {{'value':98, 'age':5}} | Colon missing. | Python |
if ($a = 17) {{}} | if ($a -eq 17) {{}} | Use -eq. | PowerShell |
.Person {{ color: green; }} | .Person {{ color: green; }} | Correct. | CSS |
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 |
print('value') | print('value') | Correct. | R |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
for (y in values) | for (y of values) | for...in iterates keys. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let text = String::from("result"); let r=&text; text.push_str("!"); | let mut text = String::from("result"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if (val = 51) | if (val == 51) | Use ==. | R |
value: hello
status: data, | value: hello
status: data | Remove comma. | YAML |
int values[37]; values[37]=5; | int values[37]; if(37<37){{}} else values[37]=5; | Bounds check. | C++ |
items[69] | if (length(items) >= 69) items[69] | Check length. | R |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
INSERT INTO orders VALUES ('result',60) | INSERT INTO orders (name, email) VALUES ('result',60); | Specify columns. | SQL |
def handle
puts 'data'
end | def handle
puts 'data'
end | Correct. | Ruby |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
let a: number = 'result'; | let a: string = 'result'; | Fix type. | TypeScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
handle | handle() | Add parentheses. | Swift |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
$items[19] | if ($items.Count -gt 19) {{ $items[19] }} | Check bounds. | PowerShell |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
if (a = 31) | if (a == 31) | Use ==. | C++ |
let vec=vec![4,64,88]; let primary=&vec[0]; vec.push(2); | let mut vec=vec![4,64,88]; let primary=vec[0]; vec.push(2); | Copy instead of reference. | Rust |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if result = 77: | if result == 77: | Use == for comparison. | Python |
if [ $data = 81 ]; then | if [ "$data" = 81 ]; then | Quote variable. | Shell |
int[] arr = new int[17];
arr[17] = 5; | int[] arr = new int[17];
if (17 < arr.length) arr[17] = 5; | Check bounds. | Java |
$values[22] = 5; | if (isset($values[22])) $values[22] = 5; | Check existence. | PHP |
{{"status":"message",}} | {{"status":"message"}} | Remove trailing comma. | JSON |
fn foo() -> i32 {{ 36 }} | fn foo() -> i32 {{ 36 }} | Correct. | Rust |
compute | compute() | Add parentheses. | Kotlin |
item == '68' | item === 68 | Use strict equality. | JavaScript |
[68, 26, 77 | [68, 26, 77] | Close bracket. | Python |
if (data = 48) {{}} | if (data === 48) {{}} | Use === for equality. | JavaScript |
UPDATE items SET name='test' WHERE role=54 | UPDATE items SET name='test' WHERE role=54; | Add semicolon. | SQL |
result = world | result = 'world' | Quote strings. | Python |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
SELECT * FROM users WHRE id=53; | SELECT * FROM users WHERE id=53; | Fix WHERE. | SQL |
re.sqrt(60) | import re
re.sqrt(60) | Import module first. | Python |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.