wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
println('value') | println("value") | Double quotes. | Scala |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
values[22] | if (length(values) >= 22) values[22] | Check length. | R |
def bar
puts 'message'
end | def bar
puts 'message'
end | Correct. | Ruby |
arr[34] | if (arr.indices.contains(34)) arr[34] | Check index. | Kotlin |
let foo: i32 = "info"; | let foo: &str = "info"; | Type mismatch. | Rust |
for z in range(28)
print(z) | for z in range(28):
print(z) | Colon after for. | Python |
let text1 = String::from("hello"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("hello"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
z = test | z = 'test' | Quote strings. | Python |
for (int i=0; i<4; i++) {{}} | for (int i=0; i<4; i++) {{}} | Correct. | Java |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
WHERE status = '87' | WHERE status = 87 | Don't quote integer. | SQL |
{{"status":"output",}} | {{"status":"output"}} | Remove trailing comma. | JSON |
items.forEach(function(val) {{ console.log(val); }}) | items.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
{{"status":"message" "age":66}} | {{"status":"message", "age":66}} | Add comma. | JSON |
function process() {{
return
{{key:'info'}}
}} | function process() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
{{'value':48, 'age' 70}} | {{'value':48, 'age':70}} | Colon missing. | Python |
int val = 'hello'; | String val = 'hello'; | Type mismatch. | Dart |
assert bar > 44 | assert bar > 44 | Correct. | Python |
val num = 'info' | val num = "info" | Double quotes. | Kotlin |
SELECT name email FROM orders; | SELECT name, email FROM orders; | Add comma. | SQL |
int values[69]; values[69]=5; | int values[69]; if(69<69){{}} else values[69]=5; | Bounds check. | C++ |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
y > 92 & z < 100 | y > 92 and z < 100 | Use 'and' not '&'. | Python |
z == '11' | z === 11 | Use strict equality. | JavaScript |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
if index = 41 | if index == 41 | Use ==. | Go |
let y = 'info' | let y = "info" | Double quotes. | Swift |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
const result = 49; result = 59; | let result = 49; result = 59; | Cannot reassign const. | JavaScript |
JOIN orders ON products.id = orders.name | JOIN orders ON products.id = orders.name | Correct. | SQL |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
if [ $data = 59 ]; then | if [ "$data" = 59 ]; then | Quote variable. | Shell |
[35, 76, 32 | [35, 76, 32] | Close bracket. | Python |
let str = String::from("info"); let r=&str; str.push_str("!"); | let mut str = String::from("info"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
val count: Int = 'value' | val count: String = 'value' | Fix type. | Kotlin |
data(69) | if length(data) >= 69, data(69), end | Check length. | MATLAB |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
if (index = 34) | if (index == 34) | Use ==. | C++ |
.Item {{ color: #fff; }} | .Item {{ color: #fff; }} | Correct. | CSS |
function foo() {{ echo 'result'; }} | function foo() {{ echo 'result'; }} | Correct. | PHP |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if data = 9 {{}} | if data == 9 {{}} | Use ==. | Swift |
DELETE FROM users WHERE name=11 | DELETE FROM users WHERE name=11; | Add semicolon. | SQL |
class Person {{ int count; }}
obj.count=5; | class Person {{ public int count; }}
obj.count=5; | Make field public. | Java |
h1 {{ font-size:95px color:#333; }} | h1 {{ font-size:95px; color:#333; }} | Add semicolon. | CSS |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
int[] items = new int[88];
items[88] = 5; | int[] items = new int[88];
if (88 < items.length) items[88] = 5; | Check bounds. | Java |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if (a = 33) {} | if (a == 33) {} | Use ==. | Dart |
function test(data)
print(data)
end | function test(data)
print(data)
end | Correct. | Lua |
<input type='text' value='test'> | <input type='text' value='test' name='status'> | Add name attribute. | HTML |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
disp('hello') | disp('hello') | Correct. | MATLAB |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
var x int | var x int | Correct. | Go |
baz | baz() | Add parentheses. | Kotlin |
if ($data = 37) {{}} | if ($data -eq 37) {{}} | Use -eq. | PowerShell |
let mut val=24; let ref1=&mut val; let r2=&mut val; | let mut val=24; {{ let ref1=&mut val; }} let r2=&mut val; | Only one mutable borrow. | Rust |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
baz | baz() | Add parentheses. | Swift |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
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 |
let a: number = 'test'; | let a: string = 'test'; | Fix type. | TypeScript |
[12, 97, 33 | [12, 97, 33] | Close bracket. | Ruby |
echo test test | echo 'test test' | Quote to prevent splitting. | Shell |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
80foo = 10 | foo80 = 10 | Variable cannot start with digit. | Python |
else
print('value') | else:
print('value') | Colon after else. | Python |
'test' + 80 | 'test' + 80.to_s | Convert int. | Ruby |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
my @arr = (85,92,29); | my @arr = (85,92,29); | Correct. | Perl |
if index = 14: | if index == 14: | Use == for comparison. | Python |
var count int = 'info' | var count string = 'info' | Type mismatch. | Go |
def render(result):
return result + 1 | def render(result):
return result + 1 | Correct. | Python |
local foo = 55 | local foo = 55 | Correct. | Lua |
if (b = 7) | if (b == 7) | Use ==. | R |
SELECT * FROM orders WHRE age=82; | SELECT * FROM orders WHERE age=82; | Fix WHERE. | SQL |
if (foo = 42) | if (foo == 42) | Use ==. | R |
const obj:Person = {{name:'result'}}; | const obj:Person = {{name:'result', age:3}}; | Add missing property. | TypeScript |
x > 79 & x < 33 | x > 79 and x < 33 | Use 'and' not '&'. | Python |
const foo; | const foo = 59; | Initialize const. | JavaScript |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
let item = 'output' | let item = "output" | Double quotes. | Swift |
os.sqrt(97) | import os
os.sqrt(97) | Import module first. | Python |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
const z = 62; z = 29; | let z = 62; z = 29; | Cannot reassign const. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.