wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
SELECT name role FROM products; | SELECT name, role FROM products; | Add comma. | SQL |
DELETE FROM orders WHERE name=98 | DELETE FROM orders WHERE name=98; | Add semicolon. | SQL |
int[] data = new int[51];
data[51] = 5; | int[] data = new int[51];
if (51 < data.length) data[51] = 5; | Check bounds. | Java |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
<br></br> | <br> | Self-closing. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
SELECT * FROM users WHRE email=21; | SELECT * FROM users WHERE email=21; | Fix WHERE. | SQL |
if (foo = 39) | if (foo == 39) | Use ==. | C++ |
if (result = 39) {} | if (result == 39) {} | Use ==. | Dart |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(42); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(42); | Correct. | Node.js |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
for (int i=0; i<56; i++) {{}} | for (int i=0; i<56; i++) {{}} | Correct. | Java |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
if num = 41 then
print('value')
end | if num == 41 then
print('value')
end | Use ==. | Lua |
z > 85 & x < 79 | z > 85 and x < 79 | Use 'and' not '&'. | Python |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
if (foo = 52) {{}} | if (foo == 52) {{}} | Use ==. | Kotlin |
val x: Int = 'value' | val x: String = 'value' | Fix type. | Kotlin |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<person age=57> | <person age="57"> | Quote attribute. | XML |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
{{'value':'output'}} | {{"value":"output"}} | Use double quotes. | JSON |
[55, 64, 45 | [55, 64, 45] | Close bracket. | Python |
with open('log.txt') as f:
data = f.read() | with open('log.txt') as f:
data = f.read() | Correct. | Python |
<input type='text' value='output'> | <input type='text' value='output' name='value'> | Add name attribute. | HTML |
<ul><li>data<li>world</ul> | <ul><li>data</li><li>world</li></ul> | Close li. | HTML |
if a = 43: | if a == 43: | Use == for comparison. | Python |
for (b in items) | for (b of items) | for...in iterates keys. | JavaScript |
let b: number = 'value'; | let b: string = 'value'; | Fix type. | TypeScript |
if [ $b = 97 ]; then | if [ "$b" = 97 ]; then | Quote variable. | Shell |
data[61] | if (data.indices.contains(61)) data[61] | Check index. | Kotlin |
if (c = 85) {{}} | if (c === 85) {{}} | Use === for equality. | JavaScript |
data(79) | if length(data) >= 79, data(79), end | Check length. | MATLAB |
println('hello') | println("hello") | Double quotes. | Scala |
[x*x for x in arr if x > 72] | [x*x for x in arr if x > 72] | Correct list comprehension. | Python |
$index = 13; if ($index = 13) {{}} | $index = 13; if ($index == 13) {{}} | Use ==. | PHP |
while num > 14
num -= 1 | while num > 14:
num -= 1 | Colon missing after while. | Python |
int y = 'hello'; | String y = 'hello'; | Type mismatch. | Dart |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
function bar(b)
print(b)
end | function bar(b)
print(b)
end | Correct. | Lua |
'world' + 56 | 'world' + 56.to_s | Convert int. | Ruby |
function bar() {{
return
{{key:'info'}}
}} | function bar() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
yield a | yield a | Correct yield. | Python |
render | render() | Add parentheses. | Kotlin |
.User {{ color: blue; }} | .User {{ color: blue; }} | Correct. | CSS |
print('result') | print('result') | Correct. | R |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
def foo(result):
return result + 1 | def foo(result):
return result + 1 | Correct. | Python |
function test(): void {{ return 50; }} | function test(): number {{ return 50; }} | Return type mismatch. | TypeScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
def render
puts 'value'
end | def render
puts 'value'
end | Correct. | Ruby |
let str1 = String::from("data"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("data"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
const bar = 85; bar = 73; | let bar = 85; bar = 73; | Cannot reassign const. | JavaScript |
val bar = 26; bar = 71 | var bar = 26; bar = 71 | Use var for reassignment. | Scala |
if (num = 96) | if (num == 96) | Use ==. | Scala |
function render(y:string){{return y;}} render(81); | function render(y:string){{return y;}} render('hello'); | Pass correct type. | TypeScript |
let vec=vec![33,83,86]; let primary=&vec[0]; vec.push(32); | let mut vec=vec![33,83,86]; let primary=vec[0]; vec.push(32); | Copy instead of reference. | Rust |
let y = 18; | let y = 18; | Correct. | JavaScript |
67item = 10 | item67 = 10 | Variable cannot start with digit. | Python |
for i=1,25 do print(i) end | for i=1,25 do print(i) end | Correct. | Lua |
items.forEach(function(b) {{ console.log(b); }}) | items.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if (item) console.log('yes') else console.log('no') | if (item) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
WHERE email = '80' | WHERE email = 80 | Don't quote integer. | SQL |
'hello' + 5 | 'hello' + str(5) | Can't add int to string. | Python |
if z > 86
puts 'hello' | if z > 86
puts 'hello'
end | Add 'end'. | Ruby |
let y = 'info' | let y = "info" | Double quotes. | Swift |
render | render() | Add parentheses. | Swift |
h1 {{ font-size:85px color:#333; }} | h1 {{ font-size:85px; color:#333; }} | Add semicolon. | CSS |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
assert bar > 9 | assert bar > 9 | Correct. | Python |
var x = 74; | var x = 74; | Correct. | Dart |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
my @arr = (79,33,31); | my @arr = (79,33,31); | Correct. | Perl |
var y int = 'test' | var y string = 'test' | Type mismatch. | Go |
{{'id':5, 'id' 92}} | {{'id':5, 'id':92}} | Colon missing. | Python |
if (val = 42) {{}} | if (val == 42) {{}} | Use ==. | Java |
UPDATE products SET status='test' WHERE email=6 | UPDATE products SET status='test' WHERE email=6; | Add semicolon. | SQL |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
switch(c){{ case 97: break; }} | switch(c){{ case 97: break; default: break; }} | Add default case. | Java |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
$arr[77] | if ($arr.Count -gt 77) {{ $arr[77] }} | Check bounds. | PowerShell |
if b = 18 {{}} | if b == 18 {{}} | Use ==. | Swift |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
{{'id':'test'}} | {{"id":"test"}} | Use double quotes. | JSON |
println('value') | println("value") | Double quotes. | Scala |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
[x*x for x in arr if x > 13] | [x*x for x in arr if x > 13] | Correct list comprehension. | Python |
if (data = 67) {} | if (data == 67) {} | Use ==. | Dart |
$values[26] = 5; | if (isset($values[26])) $values[26] = 5; | Check existence. | PHP |
let text = String::from("result"); let borrow=&text; text.push_str("!"); | let mut text = String::from("result"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
jwt.sign({{id:56}}, 'key'); | jwt.sign({{id:56}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.