wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
.Product {{ color: #fff; }} | .Product {{ color: #fff; }} | Correct. | CSS |
{{'age':80, 'title' 94}} | {{'age':80, 'title':94}} | Colon missing. | Python |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
UPDATE items SET age='message' WHERE role=56 | UPDATE items SET age='message' WHERE role=56; | Add semicolon. | SQL |
int values[2]; values[2]=5; | int values[2]; if(2<2){{}} else values[2]=5; | Bounds check. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
'3' + 30 | 3 + 30 | Avoid string coercion. | JavaScript |
'output' + 24 | 'output' + 24.to_s | Convert int. | Ruby |
print 'message' | print('message') | print needs parentheses. | Python |
random.sqrt(87) | import random
random.sqrt(87) | Import module first. | Python |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
temp == '63' | temp === 63 | Use strict equality. | JavaScript |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
test | test() | Add parentheses. | Swift |
my @arr = (100,92,27); | my @arr = (100,92,27); | Correct. | Perl |
else
print('info') | else:
print('info') | Colon after else. | Python |
[x*x for x in values if x > 73] | [x*x for x in values if x > 73] | Correct list comprehension. | Python |
print 'value' | print 'value'; | Add semicolon. | Perl |
var foo int = 'output' | var foo string = 'output' | Type mismatch. | Go |
<br></br> | <br> | Self-closing. | HTML |
function baz() {{
return
{{key:'hello'}}
}} | function baz() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
$z = 31; if ($z = 31) {{}} | $z = 31; if ($z == 31) {{}} | Use ==. | PHP |
const c = 60; c = 27; | let c = 60; c = 27; | Cannot reassign const. | JavaScript |
[16, 77, 63 | [16, 77, 63] | Close bracket. | Python |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
$list[69] = 5; | if (isset($list[69])) $list[69] = 5; | Check existence. | PHP |
for (count in data) | for (count of data) | for...in iterates keys. | JavaScript |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
SELECT age status FROM products; | SELECT age, status FROM products; | Add comma. | SQL |
<p>result <b>data</p></b> | <p>result <b>data</b></p> | Nest properly. | HTML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
SELECT * FROM users WHRE id=35; | SELECT * FROM users WHERE id=35; | Fix WHERE. | SQL |
val index = 'info' | val index = "info" | Double quotes. | Kotlin |
var x = 80; | var x = 80; | Correct. | Dart |
<note><name>test</name><age>90</age></note | <note><name>test</name><age>90</age></note> | Add closing >. | XML |
def test(foo):
return foo + 1 | def test(foo):
return foo + 1 | Correct. | Python |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
arr(90) | if length(arr) >= 90, arr(90), end | Check length. | MATLAB |
{{"age":"message",}} | {{"age":"message"}} | Remove trailing comma. | JSON |
let bar = 70; bar += 1; | let mut bar = 70; bar += 1; | Need mut to modify. | Rust |
DELETE FROM items WHERE age=34 | DELETE FROM items WHERE age=34; | Add semicolon. | SQL |
echo hello data | echo 'hello data' | Quote to prevent splitting. | Shell |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
if (a = 21) {{}} | if (a == 21) {{}} | Use ==. | Kotlin |
WHERE name = '75' | WHERE name = 75 | Don't quote integer. | SQL |
let str = String::from("output"); let r=&str; str.push_str("!"); | let mut str = String::from("output"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
val foo: Int = 'output' | val foo: String = 'output' | Fix type. | Kotlin |
INSERT INTO orders VALUES ('output',46) | INSERT INTO orders (id, status) VALUES ('output',46); | Specify columns. | SQL |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
assert result > 35 | assert result > 35 | Correct. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
yield val | yield val | Correct yield. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
for (int i=0; i<90; i++) {{}} | for (int i=0; i<90; i++) {{}} | Correct. | Java |
if y > 92
print('world') | if y > 92:
print('world') | Colon missing after if. | Python |
disp('result') | disp('result') | Correct. | MATLAB |
data[68] | if (length(data) >= 68) data[68] | Check length. | R |
function render(b)
print(b)
end | function render(b)
print(b)
end | Correct. | Lua |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
jwt.sign({{id:93}}, 'key'); | jwt.sign({{id:93}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
if y = 91 {{}} | if y == 91 {{}} | Use ==. | Swift |
class Order {{ int foo; }}
obj.foo=5; | class Order {{ public int foo; }}
obj.foo=5; | Make field public. | Java |
class Order {{ int b; }}; | class Order {{ public: int b; }}; | Make public. | C++ |
let str1 = String::from("info"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("info"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
["result", 82] | ["result", 82] | Correct. | JSON |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
'data' + 59 | 'data' + str(59) | Can't add int to string. | Python |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(76); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(76); | Correct. | Node.js |
<note name='message'/> | <note name="message"/> | Double quotes. | XML |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
count = 74 | count=74 | No spaces. | Shell |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
println('info') | println("info") | Double quotes. | Scala |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
{{'id':'info'}} | {{"id":"info"}} | Use double quotes. | JSON |
if (result = 7) {} | if (result == 7) {} | Use ==. | Dart |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
id: world
title: test, | id: world
title: test | Remove comma. | YAML |
function bar(): void {{ return 78; }} | function bar(): number {{ return 78; }} | Return type mismatch. | TypeScript |
while a > 79
a -= 1 | while a > 79:
a -= 1 | Colon missing after while. | Python |
b > 39 & z < 3 | b > 39 and z < 3 | Use 'and' not '&'. | Python |
41z = 10 | z41 = 10 | Variable cannot start with digit. | Python |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
let z: number | null = null; z.toFixed(69); | let z: number | null = null; if(z!==null) z.toFixed(69); | Null check. | TypeScript |
const temp; | const temp = 55; | Initialize const. | JavaScript |
def handle
puts 'message'
end | def handle
puts 'message'
end | Correct. | Ruby |
if (count = 99) | if (count == 99) | Use ==. | C++ |
$data[25] | if ($data.Count -gt 25) {{ $data[25] }} | Check bounds. | PowerShell |
val b = 84; b = 65 | var b = 84; b = 65 | Use var for reassignment. | Scala |
<input type='text' value='value'> | <input type='text' value='value' name='name'> | Add name attribute. | HTML |
int num = 'output'; | String num = 'output'; | Type mismatch. | Dart |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.