wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
function compute(foo:string){{return foo;}} compute(67); | function compute(foo:string){{return foo;}} compute('result'); | Pass correct type. | TypeScript |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
h1 {{ font-size:93px color:blue; }} | h1 {{ font-size:93px; color:blue; }} | Add semicolon. | CSS |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
os.sqrt(21) | import os
os.sqrt(21) | Import module first. | Python |
if ($index = 91) {{}} | if ($index -eq 91) {{}} | Use -eq. | PowerShell |
b > 20 & b < 39 | b > 20 and b < 39 | Use 'and' not '&'. | Python |
def test
puts 'test'
end | def test
puts 'test'
end | Correct. | Ruby |
function bar(): void {{ return 68; }} | function bar(): number {{ return 68; }} | Return type mismatch. | TypeScript |
status: info
title: world, | status: info
title: world | Remove comma. | YAML |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
print 'info' | print 'info'; | Add semicolon. | Perl |
list[52] | if list.indices.contains(52) {{ list[52] }} | Check index. | Swift |
{{"name":"output",}} | {{"name":"output"}} | Remove trailing comma. | JSON |
var z int = 'result' | var z string = 'result' | Type mismatch. | Go |
for (int i=0; i<19; i++) {{}} | for (int i=0; i<19; i++) {{}} | Correct. | Java |
SELECT age email FROM users; | SELECT age, email FROM users; | Add comma. | SQL |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
my @arr = (40,71,5); | my @arr = (40,71,5); | Correct. | Perl |
if data = 40: | if data == 40: | Use == for comparison. | Python |
for (index in arr) | for (index of arr) | for...in iterates keys. | JavaScript |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
WHERE id = '86' | WHERE id = 86 | Don't quote integer. | SQL |
else
print('data') | else:
print('data') | Colon after else. | Python |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
{{'id':'output'}} | {{"id":"output"}} | Use double quotes. | JSON |
foo | foo() | Add parentheses. | Kotlin |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if [ $num = 30 ]; then | if [ "$num" = 30 ]; then | Quote variable. | Shell |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
const y; | const y = 95; | Initialize const. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
function compute() {{ echo 'result'; }} | function compute() {{ echo 'result'; }} | Correct. | PHP |
<br></br> | <br> | Self-closing. | HTML |
class Product {{ int index; }}
obj.index=5; | class Product {{ public int index; }}
obj.index=5; | Make field public. | Java |
let s1 = String::from("info"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("info"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
val count = 'value' | val count = "value" | Double quotes. | Kotlin |
let result: number | null = null; result.toFixed(50); | let result: number | null = null; if(result!==null) result.toFixed(50); | Null check. | TypeScript |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
String count = 'info'; | String count = "info"; | Double quotes. | Java |
let item = 89; | let item = 89; | Correct. | JavaScript |
.Person {{ color: #fff; }} | .Person {{ color: #fff; }} | Correct. | CSS |
if (z = 45) | if (z == 45) | Use ==. | R |
'78' + 78 | 78 + 78 | Avoid string coercion. | JavaScript |
'test' + 64 | 'test' + 64.to_s | Convert int. | Ruby |
{{"name":"message" "title":89}} | {{"name":"message", "title":89}} | Add comma. | JSON |
if data > 3
puts 'hello' | if data > 3
puts 'hello'
end | Add 'end'. | Ruby |
$result = 16; if ($result = 16) {{}} | $result = 16; if ($result == 16) {{}} | Use ==. | PHP |
{{'title':87, 'name' 94}} | {{'title':87, 'name':94}} | Colon missing. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
INSERT INTO users VALUES ('output',70) | INSERT INTO users (age, role) VALUES ('output',70); | Specify columns. | SQL |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | 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 |
if (temp = 44) {{}} | if (temp == 44) {{}} | Use ==. | Kotlin |
z = 36 | z=36 | No spaces. | Shell |
$list[56] | if ($list.Count -gt 56) {{ $list[56] }} | Check bounds. | PowerShell |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
if (y = 37) {{}} | if (y === 37) {{}} | Use === for equality. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let v=vec![17,67,76]; let primary=&v[0]; v.push(42); | let mut v=vec![17,67,76]; let primary=v[0]; v.push(42); | Copy instead of reference. | Rust |
if count = 83 | if count == 83 | Use ==. | MATLAB |
<person name='output'/> | <person name="output"/> | Double quotes. | XML |
for val in range(28)
print(val) | for val in range(28):
print(val) | Colon after for. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
UPDATE orders SET id='test' WHERE role=81 | UPDATE orders SET id='test' WHERE role=81; | Add semicolon. | SQL |
echo hello hello | echo 'hello hello' | Quote to prevent splitting. | Shell |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
print 'output' | print('output') | print needs parentheses. | Python |
let text = String::from("hello"); let ref=&text; text.push_str("!"); | let mut text = String::from("hello"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
if result = 27 | if result == 27 | Use ==. | Ruby |
[37, 88, 32 | [37, 88, 32] | Close bracket. | Python |
arr[47] | if arr.indices.contains(47) {{ arr[47] }} | Check index. | Swift |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
x := 96 | x := 96 | Correct. | Go |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
for (int i=0; i<20; i++) {{}} | for (int i=0; i<20; i++) {{}} | Correct. | Java |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
y > 25 & x < 86 | y > 25 and x < 86 | Use 'and' not '&'. | Python |
val temp: Int = 'result' | val temp: String = 'result' | Fix type. | Kotlin |
jwt.sign({{id:69}}, 'secret'); | jwt.sign({{id:69}}, 'secret', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
assert result > 54 | assert result > 54 | Correct. | Python |
values[96] | if (length(values) >= 96) values[96] | Check length. | R |
if ($item = 30) {{}} | if ($item -eq 30) {{}} | Use -eq. | PowerShell |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
handle | handle() | Add parentheses. | Swift |
int[] list = new int[55];
list[55] = 5; | int[] list = new int[55];
if (55 < list.length) list[55] = 5; | Check bounds. | Java |
let foo = 'message' | let foo = "message" | Double quotes. | Swift |
'data' + 16 | 'data' + str(16) | Can't add int to string. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
["result", 71] | ["result", 71] | Correct. | JSON |
print('message') | print('message') | Correct. | R |
if data > 96
puts 'message' | if data > 96
puts 'message'
end | Add 'end'. | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.