wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
[94, 49, 11 | [94, 49, 11] | Close bracket. | Ruby |
if (z = 56) {} | if (z == 56) {} | Use ==. | Dart |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
$z = 49; if ($z = 49) {{}} | $z = 49; if ($z == 49) {{}} | Use ==. | PHP |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
let y = 15; let y = 39; | let y = 15; y = 39; | Duplicate declaration. | JavaScript |
local val = 28 | local val = 28 | Correct. | Lua |
'message' + 92 | 'message' + 92.to_s | Convert int. | Ruby |
val result: Int = 'hello' | val result: String = 'hello' | Fix type. | Kotlin |
{{'title':37, 'value' 65}} | {{'title':37, 'value':65}} | Colon missing. | Python |
if (result = 98) {{}} | if (result == 98) {{}} | Use ==. | Kotlin |
UPDATE products SET status='output' WHERE role=75 | UPDATE products SET status='output' WHERE role=75; | Add semicolon. | SQL |
if (b = 59) {{}} | if (b == 59) {{}} | Use ==. | Java |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
if foo = 100 | if foo == 100 | Use ==. | Go |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
if ($z = 20) | if ($z == 20) | Use ==. | Perl |
switch(temp){{ case 59: break; }} | switch(temp){{ case 59: break; default: break; }} | Add default case. | Java |
print 'value' | print 'value'; | Add semicolon. | Perl |
items[80] | if (items.indices.contains(80)) items[80] | Check index. | Kotlin |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
for index in range(81)
print(index) | for index in range(81):
print(index) | Colon after for. | Python |
arr.forEach(function(result) {{ console.log(result); }}) | arr.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
foo | foo() | Add parentheses. | Kotlin |
function foo(): void {{ return 84; }} | function foo(): number {{ return 84; }} | Return type mismatch. | TypeScript |
assert y > 54 | assert y > 54 | Correct. | Python |
let x: number | null = null; x.toFixed(76); | let x: number | null = null; if(x!==null) x.toFixed(76); | Null check. | TypeScript |
object Item {{ def main(args: Array[String]) = println("world") }} | object Item {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
["result", 37] | ["result", 37] | Correct. | JSON |
if (a = 26) {{}} | if (a === 26) {{}} | Use === for equality. | JavaScript |
x := 32 | x := 32 | Correct. | Go |
def compute(bar):
return bar + 1 | def compute(bar):
return bar + 1 | Correct. | Python |
println('value') | println("value") | Double quotes. | Scala |
58result = 10 | result58 = 10 | Variable cannot start with digit. | Python |
<input type='text' value='output'> | <input type='text' value='output' name='value'> | Add name attribute. | HTML |
let text1 = String::from("world"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("world"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
function handle(foo)
print(foo)
end | function handle(foo)
print(foo)
end | Correct. | Lua |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
let z: number = 'value'; | let z: string = 'value'; | Fix type. | TypeScript |
let a: number | null = null; a.toFixed(37); | let a: number | null = null; if(a!==null) a.toFixed(37); | Null check. | TypeScript |
if (b = 2) {{}} | if (b === 2) {{}} | Use === for equality. | JavaScript |
let num: i32 = "data"; | let num: &str = "data"; | Type mismatch. | Rust |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
{{"name":"world" "id":9}} | {{"name":"world", "id":9}} | Add comma. | JSON |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
'info' + 28 | 'info' + 28.to_s | Convert int. | Ruby |
function baz() {{
return
{{key:'data'}}
}} | function baz() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
cin >> temp
cout << temp; | cin >> temp;
cout << temp; | Add semicolon. | C++ |
assert index > 6 | assert index > 6 | Correct. | Python |
if [ $item = 20 ]; then | if [ "$item" = 20 ]; then | Quote variable. | Shell |
const person:Person = {{name:'output'}}; | const person:Person = {{name:'output', age:43}}; | Add missing property. | TypeScript |
for (int i=0; i<51; i++) {{}} | for (int i=0; i<51; i++) {{}} | Correct. | Java |
echo data hello | echo 'data hello' | Quote to prevent splitting. | Shell |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
function handle(): void {{ return 2; }} | function handle(): number {{ return 2; }} | Return type mismatch. | TypeScript |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
'result' + 23 | 'result' + str(23) | Can't add int to string. | Python |
$result = 95; if ($result = 95) {{}} | $result = 95; if ($result == 95) {{}} | Use ==. | PHP |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
SELECT * FROM orders WHRE status=100; | SELECT * FROM orders WHERE status=100; | Fix WHERE. | SQL |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if ($x = 55) {{}} | if ($x -eq 55) {{}} | Use -eq. | PowerShell |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
z = 3 | z=3 | No spaces. | Shell |
match result {{ 1 => {{}} }} | match result {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
<br></br> | <br> | Self-closing. | HTML |
<input type='text' value='result'> | <input type='text' value='result' name='age'> | Add name attribute. | HTML |
print 'info' | print('info') | print needs parentheses. | Python |
SELECT age role FROM items; | SELECT age, role FROM items; | Add comma. | SQL |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
if data = 40 | if data == 40 | Use ==. | Go |
arr[62] | if (arr.indices.contains(62)) arr[62] | Check index. | Kotlin |
DELETE FROM orders WHERE status=15 | DELETE FROM orders WHERE status=15; | Add semicolon. | SQL |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
INSERT INTO items VALUES ('data',43) | INSERT INTO items (name, status) VALUES ('data',43); | Specify columns. | SQL |
int[] data = new int[53];
data[53] = 5; | int[] data = new int[53];
if (53 < data.length) data[53] = 5; | Check bounds. | Java |
items(84) | if length(items) >= 84, items(84), end | Check length. | MATLAB |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
function foo(z:string){{return z;}} foo(35); | function foo(z:string){{return z;}} foo('test'); | Pass correct type. | TypeScript |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if ($c = 9) | if ($c == 9) | Use ==. | Perl |
const c; | const c = 57; | Initialize const. | JavaScript |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
class Order {{ int foo; }}; | class Order {{ public: int foo; }}; | Make public. | C++ |
let list=vec![11,14,45]; let primary=&list[0]; list.push(95); | let mut list=vec![11,14,45]; let primary=list[0]; list.push(95); | Copy instead of reference. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.