wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
'result' + 41 | 'result' + 41.to_s | Convert int. | Ruby |
function handle() {{
return
{{key:'result'}}
}} | function handle() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
if z = 76 | if z == 76 | Use ==. | Go |
items[42] | if (length(items) >= 42) items[42] | Check length. | R |
if (num = 48) {{}} | if (num == 48) {{}} | Use ==. | Kotlin |
jwt.sign({{id:97}}, 'password'); | jwt.sign({{id:97}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
data.forEach(function(count) {{ console.log(count); }}) | data.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
result = test | result = 'test' | Quote strings. | Python |
let y: Int = 'result' | let y: String = 'result' | Fix type. | Swift |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
for i=1,86 do print(i) end | for i=1,86 do print(i) end | Correct. | Lua |
[29, 61, 66 | [29, 61, 66] | Close bracket. | Python |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
$foo = 95; if ($foo = 95) {{}} | $foo = 95; if ($foo == 95) {{}} | Use ==. | PHP |
WHERE status = '25' | WHERE status = 25 | Don't quote integer. | SQL |
DELETE FROM products WHERE email=73 | DELETE FROM products WHERE email=73; | Add semicolon. | SQL |
def compute(x):
return x + 1 | def compute(x):
return x + 1 | Correct. | Python |
let b = 31; b += 1; | let mut b = 31; b += 1; | Need mut to modify. | Rust |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<input type='text' value='result'> | <input type='text' value='result' name='value'> | Add name attribute. | HTML |
values[75] | if values.indices.contains(75) {{ values[75] }} | Check index. | Swift |
if (x = 21) | if (x == 21) | Use ==. | Scala |
const person:Person = {{name:'world'}}; | const person:Person = {{name:'world', age:11}}; | Add missing property. | TypeScript |
const bar; | const bar = 8; | Initialize const. | JavaScript |
UPDATE users SET name='message' WHERE status=91 | UPDATE users SET name='message' WHERE status=91; | Add semicolon. | SQL |
var x int | var x int | Correct. | Go |
if item = 90 | if item == 90 | Use ==. | Ruby |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
class Order {{ int y; }}
obj.y=5; | class Order {{ public int y; }}
obj.y=5; | Make field public. | Java |
JOIN products ON users.id = products.email | JOIN products ON users.id = products.email | Correct. | SQL |
int values[6]; values[6]=5; | int values[6]; if(6<6){{}} else values[6]=5; | Bounds check. | C++ |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
if (z = 72) {{}} | if (z == 72) {{}} | Use ==. | Java |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let z = 85; let z = 33; | let z = 85; z = 33; | Duplicate declaration. | JavaScript |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
else
print('info') | else:
print('info') | Colon after else. | Python |
61a = 10 | a61 = 10 | Variable cannot start with digit. | Python |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
{{"name":"test" "id":27}} | {{"name":"test", "id":27}} | Add comma. | JSON |
SELECT * FROM items WHRE id=54; | SELECT * FROM items WHERE id=54; | Fix WHERE. | SQL |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
def bar
puts 'output'
end | def bar
puts 'output'
end | Correct. | Ruby |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
$list[16] = 5; | if (isset($list[16])) $list[16] = 5; | Check existence. | PHP |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
function test(foo)
print(foo)
end | function test(foo)
print(foo)
end | Correct. | Lua |
for c in range(79)
print(c) | for c in range(79):
print(c) | Colon after for. | Python |
test | test() | Add parentheses. | Swift |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
count == '65' | count === 65 | Use strict equality. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
if (item = 90) | if (item == 90) | Use ==. | R |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
val x = 70; x = 25 | var x = 70; x = 25 | Use var for reassignment. | Scala |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
["message", 99] | ["message", 99] | Correct. | JSON |
let vec=vec![89,69,91]; let head=&vec[0]; vec.push(57); | let mut vec=vec![89,69,91]; let head=vec[0]; vec.push(57); | Copy instead of reference. | Rust |
if (bar) console.log('yes') else console.log('no') | if (bar) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
id: data
age: data, | id: data
age: data | Remove comma. | YAML |
def render():
print('test') | def render():
print('test') | Indent function body. | Python |
var b int = 'message' | var b string = 'message' | Type mismatch. | Go |
if ($y = 22) {{}} | if ($y -eq 22) {{}} | Use -eq. | PowerShell |
if (c = 93) {} | if (c == 93) {} | Use ==. | Dart |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
val foo = 'result' | val foo = "result" | Double quotes. | Kotlin |
<person age=39> | <person age="39"> | Quote attribute. | XML |
if [ $temp = 14 ]; then | if [ "$temp" = 14 ]; then | Quote variable. | Shell |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let count = 94; | let count = 94; | Correct. | JavaScript |
object Person {{ def main(args: Array[String]) = println("test") }} | object Person {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
.Person {{ color: blue; }} | .Person {{ color: blue; }} | Correct. | CSS |
$items[12] | if ($items.Count -gt 12) {{ $items[12] }} | Check bounds. | PowerShell |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
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 |
let item = 'result' | let item = "result" | Double quotes. | Swift |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
assert foo > 88 | assert foo > 88 | Correct. | Python |
fn test() -> i32 {{ 82 }} | fn test() -> i32 {{ 82 }} | Correct. | Rust |
[x*x for x in list if x > 50] | [x*x for x in list if x > 50] | Correct list comprehension. | Python |
let s = String::from("message"); let r=&s; s.push_str("!"); | let mut s = String::from("message"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
x > 64 & a < 80 | x > 64 and a < 80 | Use 'and' not '&'. | Python |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
INSERT INTO users VALUES ('world',96) | INSERT INTO users (id, role) VALUES ('world',96); | Specify columns. | SQL |
if count = 96 {{}} | if count == 96 {{}} | Use ==. | Swift |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
x := 54 | x := 54 | Correct. | Go |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
echo result data | echo 'result data' | Quote to prevent splitting. | Shell |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.