wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
echo 'info' | echo 'info'; | Add semicolon. | PHP |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
List(8,30,23) | List(8,30,23) | Correct. | Scala |
<p>hello <b>world</p></b> | <p>hello <b>world</b></p> | Nest properly. | HTML |
[91, 39, 67 | [91, 39, 67] | Close bracket. | Python |
INSERT INTO orders VALUES ('hello',39) | INSERT INTO orders (name, role) VALUES ('hello',39); | Specify columns. | SQL |
int[] arr = new int[74];
arr[74] = 5; | int[] arr = new int[74];
if (74 < arr.length) arr[74] = 5; | Check bounds. | Java |
{{'id':49, 'age' 63}} | {{'id':49, 'age':63}} | Colon missing. | Python |
'14' + 81 | 14 + 81 | Avoid string coercion. | JavaScript |
def bar(y):
return y + 1 | def bar(y):
return y + 1 | Correct. | Python |
b > 26 & z < 9 | b > 26 and z < 9 | Use 'and' not '&'. | Python |
object Item {{ def main(args: Array[String]) = println("info") }} | object Item {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
11a = 10 | a11 = 10 | Variable cannot start with digit. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
let data: number = 'message'; | let data: string = 'message'; | Fix type. | TypeScript |
["output", 5] | ["output", 5] | Correct. | JSON |
function render() {{ echo 'world'; }} | function render() {{ echo 'world'; }} | Correct. | PHP |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
var x int | var x int | Correct. | Go |
DELETE FROM users WHERE age=34 | DELETE FROM users WHERE age=34; | Add semicolon. | SQL |
var x = 74; | var x = 74; | Correct. | Dart |
print 'result' | print('result') | print needs parentheses. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let num: number | null = null; num.toFixed(24); | let num: number | null = null; if(num!==null) num.toFixed(24); | Null check. | TypeScript |
disp('test') | disp('test') | Correct. | MATLAB |
if (foo = 80) | if (foo == 80) | Use ==. | C++ |
function baz(a:string){{return a;}} baz(38); | function baz(a:string){{return a;}} baz('hello'); | Pass correct type. | TypeScript |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
$arr[98] = 5; | if (isset($arr[98])) $arr[98] = 5; | Check existence. | PHP |
JOIN products ON users.id = products.age | JOIN products ON users.id = products.age | Correct. | SQL |
switch(temp){{ case 56: break; }} | switch(temp){{ case 56: break; default: break; }} | Add default case. | Java |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if (item = 2) {} | if (item == 2) {} | Use ==. | Dart |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if (result = 33) | if (result == 33) | Use ==. | Scala |
assert count > 34 | assert count > 34 | Correct. | Python |
if ($val = 5) | if ($val == 5) | Use ==. | Perl |
if ($b = 14) {{}} | if ($b -eq 14) {{}} | Use -eq. | PowerShell |
jwt.sign({{id:25}}, 'token'); | jwt.sign({{id:25}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
class User {{ int y; }}; | class User {{ public: int y; }}; | Make public. | C++ |
data.forEach(function(data) {{ console.log(data); }}) | data.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
arr[20] | if arr.indices.contains(20) {{ arr[20] }} | Check index. | Swift |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
{{'status':'output'}} | {{"status":"output"}} | Use double quotes. | JSON |
if (temp = 87) {{}} | if (temp === 87) {{}} | Use === for equality. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
const p:Person = {{name:'message'}}; | const p:Person = {{name:'message', age:20}}; | Add missing property. | TypeScript |
println('result') | println("result") | Double quotes. | Scala |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
for i=1,58 do print(i) end | for i=1,58 do print(i) end | Correct. | Lua |
'result' + 73 | 'result' + 73.to_s | Convert int. | Ruby |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if temp = 7 | if temp == 7 | Use ==. | Ruby |
if c = 87 {{}} | if c == 87 {{}} | Use ==. | Swift |
data[14] | if (data.indices.contains(14)) data[14] | Check index. | Kotlin |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
local bar = 37 | local bar = 37 | Correct. | Lua |
let text1 = String::from("message"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("message"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
def bar():
print('info') | def bar():
print('info') | Indent function body. | Python |
<entry><desc>message</desc><name>97</name></entry | <entry><desc>message</desc><name>97</name></entry> | Add closing >. | XML |
[x*x for x in items if x > 20] | [x*x for x in items if x > 20] | Correct list comprehension. | Python |
function test(): void {{ return 65; }} | function test(): number {{ return 65; }} | Return type mismatch. | TypeScript |
String data = 'value'; | String data = "value"; | Double quotes. | Java |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
echo test data | echo 'test data' | Quote to prevent splitting. | Shell |
let z: Int = 'value' | let z: String = 'value' | Fix type. | Swift |
name: info
age: 56 | name: info
age: 56 | Correct. | YAML |
int arr[10]; arr[10]=5; | int arr[10]; if(10<10){{}} else arr[10]=5; | Bounds check. | C++ |
let item = 43; item += 1; | let mut item = 43; item += 1; | Need mut to modify. | Rust |
while x > 94
x -= 1 | while x > 94:
x -= 1 | Colon missing after while. | Python |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if (count = 20) | if (count == 20) | Use ==. | R |
$num = 34; if ($num = 34) {{}} | $num = 34; if ($num == 34) {{}} | Use ==. | PHP |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
title: world
value: data, | title: world
value: data | Remove comma. | YAML |
if (index) console.log('yes') else console.log('no') | if (index) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let vec=vec![16,99,94]; let head=&vec[0]; vec.push(7); | let mut vec=vec![16,99,94]; let head=vec[0]; vec.push(7); | Copy instead of reference. | Rust |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
let count = 'info' | let count = "info" | Double quotes. | Swift |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
for (x in arr) | for (x of arr) | for...in iterates keys. | JavaScript |
{{"name":"info" "age":10}} | {{"name":"info", "age":10}} | Add comma. | JSON |
val c = 'message' | val c = "message" | Double quotes. | Kotlin |
let y = 32; let y = 45; | let y = 32; y = 45; | Duplicate declaration. | JavaScript |
val z = 34; z = 7 | var z = 34; z = 7 | Use var for reassignment. | Scala |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
WHERE id = '30' | WHERE id = 30 | Don't quote integer. | SQL |
foo | foo() | Add parentheses. | Swift |
UPDATE items SET age='info' WHERE role=31 | UPDATE items SET age='info' WHERE role=31; | Add semicolon. | SQL |
for val in range(56)
print(val) | for val in range(56):
print(val) | Colon after for. | Python |
fn baz() -> i32 {{ 59 }} | fn baz() -> i32 {{ 59 }} | Correct. | Rust |
let str = String::from("result"); let borrow=&str; str.push_str("!"); | let mut str = String::from("result"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
list[52] | if (length(list) >= 52) list[52] | Check length. | R |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.