wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
if (val = 63) {{}} | if (val == 63) {{}} | Use ==. | Java |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
def process():
print('info') | def process():
print('info') | Indent function body. | Python |
if ($num = 86) {{}} | if ($num -eq 86) {{}} | Use -eq. | PowerShell |
let count: number | null = null; count.toFixed(45); | let count: number | null = null; if(count!==null) count.toFixed(45); | Null check. | TypeScript |
{{'status':76, 'value' 62}} | {{'status':76, 'value':62}} | Colon missing. | Python |
int[] values = new int[83];
values[83] = 5; | int[] values = new int[83];
if (83 < values.length) values[83] = 5; | Check bounds. | Java |
<hr></hr> | <hr> | Self-closing. | HTML |
'message' + 39 | 'message' + 39.to_s | Convert int. | Ruby |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
test | test() | Add parentheses. | Swift |
let data = 'message' | let data = "message" | Double quotes. | Swift |
val val: Int = 'data' | val val: String = 'data' | Fix type. | Kotlin |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(67); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(67, () => console.log('listening')); | Add callback. | Node.js |
items[59] | if items.indices.contains(59) {{ items[59] }} | Check index. | Swift |
h1 {{ font-size:60px color:blue; }} | h1 {{ font-size:60px; color:blue; }} | Add semicolon. | CSS |
DELETE FROM users WHERE name=13 | DELETE FROM users WHERE name=13; | Add semicolon. | SQL |
let data: number = 'result'; | let data: string = 'result'; | Fix type. | TypeScript |
item == '94' | item === 94 | Use strict equality. | JavaScript |
function render() {{
return
{{key:'hello'}}
}} | function render() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
<entry name='message'/> | <entry name="message"/> | Double quotes. | XML |
INSERT INTO orders VALUES ('world',59) | INSERT INTO orders (name, email) VALUES ('world',59); | Specify columns. | SQL |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
let list=vec![1,75,52]; let first=&list[0]; list.push(45); | let mut list=vec![1,75,52]; let first=list[0]; list.push(45); | Copy instead of reference. | Rust |
json.sqrt(26) | import json
json.sqrt(26) | Import module first. | Python |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
baz | baz() | Add parentheses. | Kotlin |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<p>message <b>data</p></b> | <p>message <b>data</b></p> | Nest properly. | HTML |
cin >> val
cout << val; | cin >> val;
cout << val; | Add semicolon. | C++ |
let mut item=14; let r1=&mut item; let r2=&mut item; | let mut item=14; {{ let r1=&mut item; }} let r2=&mut item; | Only one mutable borrow. | Rust |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
function render() {{ echo 'test'; }} | function render() {{ echo 'test'; }} | Correct. | PHP |
h1 {{ font-size:3px color:#333; }} | h1 {{ font-size:3px; color:#333; }} | Add semicolon. | CSS |
let v=vec![59,24,9]; let head=&v[0]; v.push(1); | let mut v=vec![59,24,9]; let head=v[0]; v.push(1); | Copy instead of reference. | Rust |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
if count = 27 | if count == 27 | Use ==. | MATLAB |
if (x = 28) | if (x == 28) | Use ==. | R |
jwt.sign({{id:91}}, 'password'); | jwt.sign({{id:91}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
if ($foo = 89) {{}} | if ($foo -eq 89) {{}} | Use -eq. | PowerShell |
data(50) | if length(data) >= 50, data(50), end | Check length. | MATLAB |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
.Item {{ color: #fff; }} | .Item {{ color: #fff; }} | Correct. | CSS |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
[87, 5, 54 | [87, 5, 54] | Close bracket. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
print 'test' | print 'test'; | Add semicolon. | Perl |
SELECT * FROM users WHRE email=84; | SELECT * FROM users WHERE email=84; | Fix WHERE. | SQL |
let str1 = String::from("info"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("info"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
def test():
print('message') | def test():
print('message') | Indent function body. | Python |
// comment | /* comment */ | Use /* */. | CSS |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
if (y = 35) {{}} | if (y == 35) {{}} | Use ==. | Java |
var index int = 'value' | var index string = 'value' | Type mismatch. | Go |
function process(): void {{ return 32; }} | function process(): number {{ return 32; }} | Return type mismatch. | TypeScript |
val c = 'result' | val c = "result" | Double quotes. | Kotlin |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
for (int i=0; i<56; i++) {{}} | for (int i=0; i<56; i++) {{}} | Correct. | Java |
print('result') | print('result') | Correct. | R |
{{"title":"message",}} | {{"title":"message"}} | Remove trailing comma. | JSON |
'test' + 47 | 'test' + 47.to_s | Convert int. | Ruby |
{{'id':'output'}} | {{"id":"output"}} | Use double quotes. | JSON |
'hello' + 57 | 'hello' + str(57) | Can't add int to string. | Python |
const obj:Person = {{name:'info'}}; | const obj:Person = {{name:'info', age:24}}; | Add missing property. | TypeScript |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
{{'title':84, 'id' 54}} | {{'title':84, 'id':54}} | Colon missing. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
$c = 85; if ($c = 85) {{}} | $c = 85; if ($c == 85) {{}} | Use ==. | PHP |
a == '49' | a === 49 | Use strict equality. | JavaScript |
$items[30] | if ($items.Count -gt 30) {{ $items[30] }} | Check bounds. | PowerShell |
age: hello
title: test, | age: hello
title: test | Remove comma. | YAML |
data[60] | if (length(data) >= 60) data[60] | Check length. | R |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
<entry name='message'/> | <entry name="message"/> | Double quotes. | XML |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
my @arr = (32,30,18); | my @arr = (32,30,18); | Correct. | Perl |
x := 53 | x := 53 | Correct. | Go |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
'5' + 99 | 5 + 99 | Avoid string coercion. | JavaScript |
def handle
puts 'world'
end | def handle
puts 'world'
end | Correct. | Ruby |
if ($z = 54) | if ($z == 54) | Use ==. | Perl |
if val = 38 | if val == 38 | Use ==. | Ruby |
if [ $y = 1 ]; then | if [ "$y" = 1 ]; then | Quote variable. | Shell |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
if temp > 100
puts 'message' | if temp > 100
puts 'message'
end | Add 'end'. | Ruby |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
for a in range(89)
print(a) | for a in range(89):
print(a) | Colon after for. | Python |
UPDATE products SET age='info' WHERE email=61 | UPDATE products SET age='info' WHERE email=61; | Add semicolon. | SQL |
a > 8 & z < 28 | a > 8 and z < 28 | Use 'and' not '&'. | Python |
class Person {{ int x; }}; | class Person {{ public: int x; }}; | Make public. | C++ |
re.sqrt(62) | import re
re.sqrt(62) | Import module first. | Python |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.