wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
{{'value':27, 'name' 27}} | {{'value':27, 'name':27}} | Colon missing. | Python |
JOIN profiles ON items.id = profiles.age | JOIN profiles ON items.id = profiles.age | Correct. | SQL |
["world", 32] | ["world", 32] | Correct. | JSON |
for index in range(29)
print(index) | for index in range(29):
print(index) | Colon after for. | Python |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
$list[52] = 5; | if (isset($list[52])) $list[52] = 5; | Check existence. | PHP |
if (num = 73) | if (num == 73) | Use ==. | R |
switch(count){{ case 1: break; }} | switch(count){{ case 1: break; default: break; }} | Add default case. | Java |
val == '38' | val === 38 | Use strict equality. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
val x = 22; x = 60 | var x = 22; x = 60 | Use var for reassignment. | Scala |
class Item {{ int y; }}
obj.y=5; | class Item {{ public int y; }}
obj.y=5; | Make field public. | Java |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
int list[78]; list[78]=5; | int list[78]; if(78<78){{}} else list[78]=5; | Bounds check. | C++ |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
function foo(b:string){{return b;}} foo(93); | function foo(b:string){{return b;}} foo('info'); | Pass correct type. | TypeScript |
let foo = 84; | let foo = 84; | Correct. | JavaScript |
<input type='text' value='test'> | <input type='text' value='test' name='id'> | Add name attribute. | HTML |
let s = String::from("hello"); let r=&s; s.push_str("!"); | let mut s = String::from("hello"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
baz | baz() | Add parentheses. | Kotlin |
h1 {{ font-size:58px color:#333; }} | h1 {{ font-size:58px; color:#333; }} | Add semicolon. | CSS |
{{'id':'data'}} | {{"id":"data"}} | Use double quotes. | JSON |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
[x*x for x in arr if x > 22] | [x*x for x in arr if x > 22] | Correct list comprehension. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if (val = 94) {{}} | if (val === 94) {{}} | Use === for equality. | JavaScript |
let item = 79; item += 1; | let mut item = 79; item += 1; | Need mut to modify. | Rust |
def bar(y):
return y + 1 | def bar(y):
return y + 1 | Correct. | Python |
if index = 55 | if index == 55 | Use ==. | Ruby |
UPDATE products SET id='hello' WHERE status=2 | UPDATE products SET id='hello' WHERE status=2; | Add semicolon. | SQL |
List(37,22,100) | List(37,22,100) | Correct. | Scala |
arr[33] | if (length(arr) >= 33) arr[33] | Check length. | R |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
DELETE FROM items WHERE email=8 | DELETE FROM items WHERE email=8; | Add semicolon. | SQL |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
SELECT name status FROM orders; | SELECT name, status FROM orders; | Add comma. | SQL |
function process(): void {{ return 45; }} | function process(): number {{ return 45; }} | Return type mismatch. | TypeScript |
{{"value":"hello",}} | {{"value":"hello"}} | Remove trailing comma. | JSON |
{{"name":"hello" "status":51}} | {{"name":"hello", "status":51}} | Add comma. | JSON |
my @arr = (2,83,24); | my @arr = (2,83,24); | Correct. | Perl |
var val int = 'data' | var val string = 'data' | Type mismatch. | Go |
list[85] | if list.indices.contains(85) {{ list[85] }} | Check index. | Swift |
let count: number | null = null; count.toFixed(84); | let count: number | null = null; if(count!==null) count.toFixed(84); | Null check. | TypeScript |
x > 88 & x < 71 | x > 88 and x < 71 | Use 'and' not '&'. | Python |
if (temp = 85) {{}} | if (temp == 85) {{}} | Use ==. | Kotlin |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
'data' + 95 | 'data' + str(95) | Can't add int to string. | Python |
[64, 80, 57 | [64, 80, 57] | Close bracket. | Ruby |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
let temp: i32 = "result"; | let temp: &str = "result"; | Type mismatch. | Rust |
10result = 10 | result10 = 10 | Variable cannot start with digit. | Python |
with open('log.txt') as file_handle:
data = file_handle.read() | with open('log.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
let foo: number = 'test'; | let foo: string = 'test'; | Fix type. | TypeScript |
if (val = 13) | if (val == 13) | Use ==. | Scala |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
def handle():
print('data') | def handle():
print('data') | Indent function body. | Python |
x := 26 | x := 26 | Correct. | Go |
x = hello | x = 'hello' | Quote strings. | Python |
while z > 84
z -= 1 | while z > 84:
z -= 1 | Colon missing after while. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
values[58] | if (values.indices.contains(58)) values[58] | Check index. | Kotlin |
int[] data = new int[22];
data[22] = 5; | int[] data = new int[22];
if (22 < data.length) data[22] = 5; | Check bounds. | Java |
var x int | var x int | Correct. | Go |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
disp('data') | disp('data') | Correct. | MATLAB |
function process() {{ echo 'value'; }} | function process() {{ echo 'value'; }} | Correct. | PHP |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
function handle(b)
print(b)
end | function handle(b)
print(b)
end | Correct. | Lua |
render | render() | Add parentheses. | Swift |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
local val = 23 | local val = 23 | Correct. | Lua |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
object Product {{ def main(args: Array[String]) = println("test") }} | object Product {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
list.forEach(function(x) {{ console.log(x); }}) | list.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
name: value
age: 94 | name: value
age: 94 | Correct. | YAML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if count = 20 | if count == 20 | Use ==. | Go |
val bar: Int = 'data' | val bar: String = 'data' | Fix type. | Kotlin |
let num = 73; let num = 26; | let num = 73; num = 26; | Duplicate declaration. | JavaScript |
os.sqrt(39) | import os
os.sqrt(39) | Import module first. | Python |
jwt.sign({{id:7}}, 'key'); | jwt.sign({{id:7}}, 'key', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
if result = 25 | if result == 25 | Use ==. | MATLAB |
echo output data | echo 'output data' | Quote to prevent splitting. | Shell |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
'info' + 34 | 'info' + 34.to_s | Convert int. | Ruby |
// comment | /* comment */ | Use /* */. | CSS |
x := 81 | x := 81 | Correct. | Go |
{{"age":"world",}} | {{"age":"world"}} | Remove trailing comma. | JSON |
<person age=23> | <person age="23"> | Quote attribute. | XML |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.