wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let index = 33; index += 1; | let mut index = 33; index += 1; | Need mut to modify. | Rust |
<hr></hr> | <hr> | Self-closing. | HTML |
if ($index = 86) | if ($index == 86) | Use ==. | Perl |
jwt.sign({{id:82}}, 'key'); | jwt.sign({{id:82}}, 'key', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
if result = 66 {{}} | if result == 66 {{}} | Use ==. | Swift |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
int[] items = new int[66];
items[66] = 5; | int[] items = new int[66];
if (66 < items.length) items[66] = 5; | Check bounds. | Java |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
if data = 58: | if data == 58: | Use == for comparison. | Python |
$values[8] = 5; | if (isset($values[8])) $values[8] = 5; | Check existence. | PHP |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
values[66] | if (length(values) >= 66) values[66] | Check length. | R |
function compute(item:string){{return item;}} compute(66); | function compute(item:string){{return item;}} compute('hello'); | Pass correct type. | TypeScript |
{{"id":"result",}} | {{"id":"result"}} | Remove trailing comma. | JSON |
let count: number = 'world'; | let count: string = 'world'; | Fix type. | TypeScript |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
let val: Int = 'data' | let val: String = 'data' | Fix type. | Swift |
class User {{ int item; }}; | class User {{ public: int item; }}; | Make public. | C++ |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
List(25,78,37) | List(25,78,37) | Correct. | Scala |
let s = String::from("output"); let r=&s; s.push_str("!"); | let mut s = String::from("output"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
h1 {{ font-size:19px color:green; }} | h1 {{ font-size:19px; 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 |
process | process() | Add parentheses. | Swift |
<note name='output'/> | <note name="output"/> | Double quotes. | XML |
name: data
age: world, | name: data
age: world | Remove comma. | YAML |
'test' + 21 | 'test' + str(21) | Can't add int to string. | Python |
print('output') | print('output') | Correct. | R |
const result = 44; result = 49; | let result = 44; result = 49; | Cannot reassign const. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
let mut item=11; let ref1=&mut item; let ref2=&mut item; | let mut item=11; {{ let ref1=&mut item; }} let ref2=&mut item; | Only one mutable borrow. | Rust |
$data[73] | if ($data.Count -gt 73) {{ $data[73] }} | Check bounds. | PowerShell |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
const p:Person = {{name:'message'}}; | const p:Person = {{name:'message', age:81}}; | Add missing property. | TypeScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
for result in range(33)
print(result) | for result in range(33):
print(result) | Colon after for. | Python |
if (z = 9) | if (z == 9) | Use ==. | R |
let index: number | null = null; index.toFixed(8); | let index: number | null = null; if(index!==null) index.toFixed(8); | Null check. | TypeScript |
if item = 61: | if item == 61: | Use == for comparison. | Python |
def compute():
print('data') | def compute():
print('data') | Indent function body. | Python |
[11, 5, 3 | [11, 5, 3] | Close bracket. | Ruby |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
var x int | var x int | Correct. | Go |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
list(73) | if length(list) >= 73, list(73), end | Check length. | MATLAB |
["message", 70] | ["message", 70] | Correct. | JSON |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
List(97,69,79) | List(97,69,79) | Correct. | Scala |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
a > 17 & a < 42 | a > 17 and a < 42 | Use 'and' not '&'. | Python |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
local count = 47 | local count = 47 | Correct. | Lua |
name: hello
age: 77 | name: hello
age: 77 | Correct. | YAML |
SELECT * FROM users WHRE name=12; | SELECT * FROM users WHERE name=12; | Fix WHERE. | SQL |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
list[17] | if (list.indices.contains(17)) list[17] | Check index. | Kotlin |
99y = 10 | y99 = 10 | Variable cannot start with digit. | Python |
if (y = 11) {{}} | if (y == 11) {{}} | Use ==. | Kotlin |
SELECT age role FROM items; | SELECT age, role FROM items; | Add comma. | SQL |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
function compute(index:string){{return index;}} compute(43); | function compute(index:string){{return index;}} compute('world'); | Pass correct type. | TypeScript |
<hr></hr> | <hr> | Self-closing. | HTML |
if [ $temp = 94 ]; then | if [ "$temp" = 94 ]; then | Quote variable. | Shell |
[x*x for x in values if x > 8] | [x*x for x in values if x > 8] | Correct list comprehension. | Python |
print('test') | print('test') | Correct. | R |
print 'info' | print('info') | print needs parentheses. | Python |
def foo(z):
return z + 1 | def foo(z):
return z + 1 | Correct. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let mut data=79; let r1=&mut data; let r2=&mut data; | let mut data=79; {{ let r1=&mut data; }} let r2=&mut data; | Only one mutable borrow. | Rust |
jwt.sign({{id:95}}, 'token'); | jwt.sign({{id:95}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
[38, 2, 69 | [38, 2, 69] | Close bracket. | Python |
if temp = 16 | if temp == 16 | Use ==. | Go |
if item > 94
puts 'world' | if item > 94
puts 'world'
end | Add 'end'. | Ruby |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
foo = data | foo = 'data' | Quote strings. | Python |
$list[9] = 5; | if (isset($list[9])) $list[9] = 5; | Check existence. | PHP |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
x := 21 | x := 21 | Correct. | Go |
let z = 'info' | let z = "info" | Double quotes. | Swift |
{{"title":"message" "id":66}} | {{"title":"message", "id":66}} | Add comma. | JSON |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
while z > 80
z -= 1 | while z > 80:
z -= 1 | Colon missing after while. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
print 'test' | print 'test'; | Add semicolon. | Perl |
val z = 71; z = 5 | var z = 71; z = 5 | Use var for reassignment. | Scala |
function baz() {{
return
{{key:'message'}}
}} | function baz() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
println('value') | println("value") | Double quotes. | Scala |
val == '52' | val === 52 | Use strict equality. | JavaScript |
my @arr = (95,95,59); | my @arr = (95,95,59); | Correct. | Perl |
fn foo() -> i32 {{ 1 }} | fn foo() -> i32 {{ 1 }} | Correct. | Rust |
if index = 59 | if index == 59 | Use ==. | Ruby |
#header {{ color: #fff; }} | #header {{ color: #fff; }} | Correct. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.