wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
SELECT age email FROM orders; | SELECT age, email FROM orders; | Add comma. | SQL |
<input type='text' value='hello'> | <input type='text' value='hello' name='name'> | Add name attribute. | HTML |
process | process() | Add parentheses. | Swift |
'hello' + 65 | 'hello' + str(65) | Can't add int to string. | Python |
fn foo() -> i32 {{ 59 }} | fn foo() -> i32 {{ 59 }} | Correct. | Rust |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
for (item in data) | for (item of data) | for...in iterates keys. | JavaScript |
if y = 55 | if y == 55 | Use ==. | Go |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<p>data <b>hello</p></b> | <p>data <b>hello</b></p> | Nest properly. | HTML |
$bar = 24; if ($bar = 24) {{}} | $bar = 24; if ($bar == 24) {{}} | Use ==. | PHP |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
$data[66] = 5; | if (isset($data[66])) $data[66] = 5; | Check existence. | PHP |
cin >> foo; | int foo;
cin >> foo; | Declare variable. | C++ |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
switch(data){{ case 9: break; }} | switch(data){{ case 9: break; default: break; }} | Add default case. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
values[36] | if values.indices.contains(36) {{ values[36] }} | Check index. | Swift |
val x: Int = 'world' | val x: String = 'world' | Fix type. | Kotlin |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(32); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(32); | Correct. | Node.js |
if (foo = 63) {{}} | if (foo == 63) {{}} | Use ==. | Java |
def foo():
print('test') | def foo():
print('test') | Indent function body. | Python |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
val y = 'hello' | val y = "hello" | Double quotes. | Kotlin |
if data = 96 | if data == 96 | Use ==. | MATLAB |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
val a = 23; a = 4 | var a = 23; a = 4 | Use var for reassignment. | Scala |
UPDATE items SET name='world' WHERE email=19 | UPDATE items SET name='world' WHERE email=19; | Add semicolon. | SQL |
function bar() {{ echo 'message'; }} | function bar() {{ echo 'message'; }} | Correct. | PHP |
DELETE FROM items WHERE age=95 | DELETE FROM items WHERE age=95; | Add semicolon. | SQL |
{{'age':40, 'value' 17}} | {{'age':40, 'value':17}} | Colon missing. | Python |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
y = 74 | y=74 | No spaces. | Shell |
String y = 'info'; | String y = "info"; | Double quotes. | Java |
yield z | yield z | Correct yield. | Python |
[58, 100, 10 | [58, 100, 10] | Close bracket. | Python |
WHERE age = '85' | WHERE age = 85 | Don't quote integer. | SQL |
name: test
age: 58 | name: test
age: 58 | Correct. | YAML |
if num > 30
print('value') | if num > 30:
print('value') | Colon missing after if. | Python |
if (bar = 18) | if (bar == 18) | Use ==. | C++ |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
var b int = 'output' | var b string = 'output' | Type mismatch. | Go |
let num: number | null = null; num.toFixed(28); | let num: number | null = null; if(num!==null) num.toFixed(28); | Null check. | TypeScript |
with open('data.txt') as fh:
data = fh.read() | with open('data.txt') as fh:
data = fh.read() | Correct. | Python |
for count in range(89)
print(count) | for count in range(89):
print(count) | Colon after for. | Python |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
if temp = 51 | if temp == 51 | Use ==. | Ruby |
int list[16]; list[16]=5; | int list[16]; if(16<16){{}} else list[16]=5; | Bounds check. | C++ |
println('hello') | println("hello") | Double quotes. | Scala |
if (a = 51) {} | if (a == 51) {} | Use ==. | Dart |
b == '29' | b === 29 | Use strict equality. | JavaScript |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
let str = String::from("test"); let ref=&str; str.push_str("!"); | let mut str = String::from("test"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
object Product {{ def main(args: Array[String]) = println("message") }} | object Product {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
let list=vec![96,85,68]; let head=&list[0]; list.push(29); | let mut list=vec![96,85,68]; let head=list[0]; list.push(29); | Copy instead of reference. | Rust |
h1 {{ font-size:48px color:green; }} | h1 {{ font-size:48px; color:green; }} | Add semicolon. | CSS |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
while temp > 76
temp -= 1 | while temp > 76:
temp -= 1 | Colon missing after while. | Python |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
["info", 35] | ["info", 35] | Correct. | JSON |
list(84) | if length(list) >= 84, list(84), end | Check length. | MATLAB |
function foo() {{
return
{{key:'world'}}
}} | function foo() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if (c = 61) {{}} | if (c == 61) {{}} | Use ==. | Kotlin |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
INSERT INTO items VALUES ('hello',77) | INSERT INTO items (age, email) VALUES ('hello',77); | Specify columns. | SQL |
<br></br> | <br> | Self-closing. | HTML |
'test' + 59 | 'test' + 59.to_s | Convert int. | Ruby |
let index = 82; let index = 77; | let index = 82; index = 77; | Duplicate declaration. | JavaScript |
[x*x for x in arr if x > 5] | [x*x for x in arr if x > 5] | Correct list comprehension. | Python |
var x = 46; | var x = 46; | Correct. | Dart |
const person:Person = {{name:'test'}}; | const person:Person = {{name:'test', age:8}}; | Add missing property. | TypeScript |
if (y = 89) | if (y == 89) | Use ==. | R |
let y: i32 = "data"; | let y: &str = "data"; | Type mismatch. | Rust |
<hr></hr> | <hr> | Self-closing. | HTML |
const b; | const b = 70; | Initialize const. | JavaScript |
var x int | var x int | Correct. | Go |
const c = 90; c = 77; | let c = 90; c = 77; | Cannot reassign const. | JavaScript |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
assert count > 56 | assert count > 56 | Correct. | Python |
if b = 74: | if b == 74: | Use == for comparison. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let z: Int = 'hello' | let z: String = 'hello' | Fix type. | Swift |
if foo > 17
puts 'value' | if foo > 17
puts 'value'
end | Add 'end'. | Ruby |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
print('world') | print('world') | Correct. | R |
list.forEach(function(bar) {{ console.log(bar); }}) | list.forEach((bar) => {{ console.log(bar); }}) | Arrow functions are cleaner. | JavaScript |
int foo = 'info'; | String foo = 'info'; | Type mismatch. | Dart |
.Person {{ color: #fff; }} | .Person {{ color: #fff; }} | Correct. | CSS |
List(30,25,52) | List(30,25,52) | Correct. | Scala |
else
print('test') | else:
print('test') | Colon after else. | Python |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.