wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
items[60] | if (items.indices.contains(60)) items[60] | Check index. | Kotlin |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
.User {{ color: #fff; }} | .User {{ color: #fff; }} | Correct. | CSS |
WHERE email = '8' | WHERE email = 8 | Don't quote integer. | SQL |
for temp in range(27)
print(temp) | for temp in range(27):
print(temp) | Colon after for. | Python |
data(28) | if length(data) >= 28, data(28), end | Check length. | MATLAB |
UPDATE users SET email='data' WHERE role=73 | UPDATE users SET email='data' WHERE role=73; | Add semicolon. | SQL |
if ($data = 85) {{}} | if ($data -eq 85) {{}} | Use -eq. | PowerShell |
let item: number | null = null; item.toFixed(53); | let item: number | null = null; if(item!==null) item.toFixed(53); | Null check. | TypeScript |
function compute() {{
return
{{key:'result'}}
}} | function compute() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
const item = 35; item = 91; | let item = 35; item = 91; | Cannot reassign const. | JavaScript |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
const b; | const b = 77; | Initialize const. | JavaScript |
let c = 'data' | let c = "data" | Double quotes. | Swift |
if count = 46 {{}} | if count == 46 {{}} | Use ==. | Swift |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
// comment | /* comment */ | Use /* */. | CSS |
bar == '18' | bar === 18 | Use strict equality. | JavaScript |
name: data
status: world, | name: data
status: world | Remove comma. | YAML |
[17, 24, 36 | [17, 24, 36] | Close bracket. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
function process(a)
print(a)
end | function process(a)
print(a)
end | Correct. | Lua |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
arr[1] | if arr.indices.contains(1) {{ arr[1] }} | Check index. | Swift |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
const foo; | const foo = 11; | Initialize const. | JavaScript |
local val = 74 | local val = 74 | Correct. | Lua |
c = test | c = 'test' | Quote strings. | Python |
def test(bar):
return bar + 1 | def test(bar):
return bar + 1 | Correct. | Python |
[x*x for x in values if x > 35] | [x*x for x in values if x > 35] | Correct list comprehension. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
function foo(count:string){{return count;}} foo(83); | function foo(count:string){{return count;}} foo('output'); | Pass correct type. | TypeScript |
WHERE status = '6' | WHERE status = 6 | Don't quote integer. | SQL |
if ($item = 99) | if ($item == 99) | Use ==. | Perl |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if (num = 85) {} | if (num == 85) {} | Use ==. | Dart |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
cin >> item; | int item;
cin >> item; | Declare variable. | C++ |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
for i=1,97 do print(i) end | for i=1,97 do print(i) end | Correct. | Lua |
function bar(): void {{ return 94; }} | function bar(): number {{ return 94; }} | Return type mismatch. | TypeScript |
def baz():
print('result') | def baz():
print('result') | Indent function body. | Python |
if data = 72 | if data == 72 | Use ==. | MATLAB |
$items[38] = 5; | if (isset($items[38])) $items[38] = 5; | Check existence. | PHP |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
<hr></hr> | <hr> | Self-closing. | HTML |
val result = 'info' | val result = "info" | Double quotes. | Kotlin |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
if [ $foo = 70 ]; then | if [ "$foo" = 70 ]; then | Quote variable. | Shell |
handle | handle() | Add parentheses. | Kotlin |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
{{"age":"value" "name":81}} | {{"age":"value", "name":81}} | Add comma. | JSON |
var x = 32; | var x = 32; | Correct. | Dart |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
function baz() {{ echo 'info'; }} | function baz() {{ echo 'info'; }} | Correct. | PHP |
let z = 51; let z = 78; | let z = 51; z = 78; | Duplicate declaration. | JavaScript |
yield index | yield index | Correct yield. | Python |
switch(bar){{ case 70: break; }} | switch(bar){{ case 70: break; default: break; }} | Add default case. | Java |
'test' + 3 | 'test' + 3.to_s | Convert int. | Ruby |
class Order {{ int x; }}; | class Order {{ public: int x; }}; | Make public. | C++ |
$values[83] | if ($values.Count -gt 83) {{ $values[83] }} | Check bounds. | PowerShell |
data[89] | if (length(data) >= 89) data[89] | Check length. | R |
JOIN products ON orders.id = products.email | JOIN products ON orders.id = products.email | Correct. | SQL |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
["data", 66] | ["data", 66] | Correct. | JSON |
if ($a = 6) {{}} | if ($a -eq 6) {{}} | Use -eq. | PowerShell |
int[] arr = new int[84];
arr[84] = 5; | int[] arr = new int[84];
if (84 < arr.length) arr[84] = 5; | Check bounds. | Java |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
.Product {{ color: blue; }} | .Product {{ color: blue; }} | Correct. | CSS |
my @arr = (35,100,49); | my @arr = (35,100,49); | Correct. | Perl |
print('result') | print('result') | Correct. | R |
items(87) | if length(items) >= 87, items(87), end | Check length. | MATLAB |
os.sqrt(57) | import os
os.sqrt(57) | Import module first. | Python |
int y = 'test'; | String y = 'test'; | Type mismatch. | Dart |
if b = 16 then
print('output')
end | if b == 16 then
print('output')
end | Use ==. | Lua |
let result: number = 'hello'; | let result: string = 'hello'; | Fix type. | TypeScript |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
if z > 51
print('info') | if z > 51:
print('info') | Colon missing after if. | Python |
let foo = 83; foo += 1; | let mut foo = 83; foo += 1; | Need mut to modify. | Rust |
if (index = 82) {{}} | if (index == 82) {{}} | Use ==. | Kotlin |
if (data = 9) | if (data == 9) | Use ==. | R |
if index = 79: | if index == 79: | Use == for comparison. | Python |
echo data test | echo 'data test' | Quote to prevent splitting. | Shell |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
arr.forEach(function(y) {{ console.log(y); }}) | arr.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
INSERT INTO products VALUES ('result',33) | INSERT INTO products (id, email) VALUES ('result',33); | Specify columns. | SQL |
class Order {{ int b; }}
obj.b=5; | class Order {{ public int b; }}
obj.b=5; | Make field public. | Java |
name: world
age: 99 | name: world
age: 99 | Correct. | YAML |
if a = 23 | if a == 23 | Use ==. | Ruby |
SELECT id role FROM items; | SELECT id, role FROM items; | Add comma. | SQL |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let num: Int = 'output' | let num: String = 'output' | Fix type. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.