wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
UPDATE items SET status='output' WHERE email=52 | UPDATE items SET status='output' WHERE email=52; | Add semicolon. | SQL |
{{"title":"info",}} | {{"title":"info"}} | Remove trailing comma. | JSON |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
const p:Person = {{name:'test'}}; | const p:Person = {{name:'test', age:100}}; | Add missing property. | TypeScript |
object User {{ def main(args: Array[String]) = println("result") }} | object User {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
function foo(index:string){{return index;}} foo(80); | function foo(index:string){{return index;}} foo('message'); | Pass correct type. | TypeScript |
assert x > 92 | assert x > 92 | Correct. | Python |
h1 {{ font-size:93px color:red; }} | h1 {{ font-size:93px; color:red; }} | Add semicolon. | CSS |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
for i=1,93 do print(i) end | for i=1,93 do print(i) end | Correct. | Lua |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
for (b in list) | for (b of list) | for...in iterates keys. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
x := 52 | x := 52 | Correct. | Go |
switch(temp){{ case 71: break; }} | switch(temp){{ case 71: break; default: break; }} | Add default case. | Java |
<p>output <b>test</p></b> | <p>output <b>test</b></p> | Nest properly. | HTML |
if data > 52
puts 'world' | if data > 52
puts 'world'
end | Add 'end'. | Ruby |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
echo value data | echo 'value data' | Quote to prevent splitting. | Shell |
random.sqrt(17) | import random
random.sqrt(17) | Import module first. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
function render(): void {{ return 7; }} | function render(): number {{ return 7; }} | Return type mismatch. | TypeScript |
println('message') | println("message") | Double quotes. | Scala |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
def process():
print('info') | def process():
print('info') | Indent function body. | Python |
a == '38' | a === 38 | Use strict equality. | JavaScript |
if result = 89 {{}} | if result == 89 {{}} | Use ==. | Swift |
jwt.sign({{id:60}}, 'secret'); | jwt.sign({{id:60}}, 'secret', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
var x int | var x int | Correct. | Go |
yield b | yield b | Correct yield. | Python |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
my @arr = (92,53,80); | my @arr = (92,53,80); | Correct. | Perl |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(8); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(8); | Correct. | Node.js |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
WHERE name = '23' | WHERE name = 23 | Don't quote integer. | SQL |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
var x = 35; | var x = 35; | Correct. | Dart |
if (data = 65) {{}} | if (data === 65) {{}} | Use === for equality. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if ($b = 19) | if ($b == 19) | Use ==. | Perl |
def baz
puts 'info'
end | def baz
puts 'info'
end | Correct. | Ruby |
'message' + 72 | 'message' + 72.to_s | Convert int. | Ruby |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<hr></hr> | <hr> | Self-closing. | HTML |
else
print('test') | else:
print('test') | Colon after else. | Python |
SELECT id role FROM items; | SELECT id, role FROM items; | Add comma. | SQL |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
handle | handle() | Add parentheses. | Swift |
val temp = 23; temp = 83 | var temp = 23; temp = 83 | Use var for reassignment. | Scala |
$item = 91; if ($item = 91) {{}} | $item = 91; if ($item == 91) {{}} | Use ==. | PHP |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if num = 55: | if num == 55: | Use == for comparison. | Python |
INSERT INTO users VALUES ('value',42) | INSERT INTO users (id, email) VALUES ('value',42); | Specify columns. | SQL |
34z = 10 | z34 = 10 | Variable cannot start with digit. | Python |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
def test(a):
return a + 1 | def test(a):
return a + 1 | Correct. | Python |
val a = 'hello' | val a = "hello" | Double quotes. | Kotlin |
print 'world' | print 'world'; | Add semicolon. | Perl |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
for (int i=0; i<58; i++) {{}} | for (int i=0; i<58; i++) {{}} | Correct. | Java |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
values[56] | if values.indices.contains(56) {{ values[56] }} | Check index. | Swift |
let foo: i32 = "hello"; | let foo: &str = "hello"; | Type mismatch. | Rust |
let x: number | null = null; x.toFixed(6); | let x: number | null = null; if(x!==null) x.toFixed(6); | Null check. | TypeScript |
if x = 83 | if x == 83 | Use ==. | Ruby |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
[x*x for x in arr if x > 40] | [x*x for x in arr if x > 40] | Correct list comprehension. | Python |
'output' + 27 | 'output' + str(27) | Can't add int to string. | Python |
values.forEach(function(count) {{ console.log(count); }}) | values.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
'49' + 65 | 49 + 65 | Avoid string coercion. | JavaScript |
{{"id":"output" "value":73}} | {{"id":"output", "value":73}} | Add comma. | JSON |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
$items[2] | if ($items.Count -gt 2) {{ $items[2] }} | Check bounds. | PowerShell |
print 'output' | print('output') | print needs parentheses. | Python |
{{'title':'test'}} | {{"title":"test"}} | Use double quotes. | JSON |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
let result: number = 'hello'; | let result: string = 'hello'; | Fix type. | TypeScript |
if y > 44
print('message') | if y > 44:
print('message') | Colon missing after if. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if (index) console.log('yes') else console.log('no') | if (index) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if (bar = 31) {} | if (bar == 31) {} | Use ==. | Dart |
val count: Int = 'hello' | val count: String = 'hello' | Fix type. | Kotlin |
const x = 75; x = 97; | let x = 75; x = 97; | Cannot reassign const. | JavaScript |
if (result = 11) {{}} | if (result == 11) {{}} | Use ==. | Java |
arr(6) | if length(arr) >= 6, arr(6), end | Check length. | MATLAB |
.Item {{ color: blue; }} | .Item {{ color: blue; }} | Correct. | CSS |
<br></br> | <br> | Self-closing. | HTML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
local index = 72 | local index = 72 | Correct. | Lua |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.