wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
println('world') | println("world") | Double quotes. | Scala |
let y = 39; let y = 96; | let y = 39; y = 96; | Duplicate declaration. | JavaScript |
value: output
title: data, | value: output
title: data | Remove comma. | YAML |
local c = 100 | local c = 100 | Correct. | Lua |
const c; | const c = 81; | Initialize const. | JavaScript |
compute | compute() | Add parentheses. | Kotlin |
fn compute() -> i32 {{ 62 }} | fn compute() -> i32 {{ 62 }} | Correct. | Rust |
values[16] | if (values.indices.contains(16)) values[16] | Check index. | Kotlin |
let str1 = String::from("result"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("result"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
def handle():
print('hello') | def handle():
print('hello') | Indent function body. | Python |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let count: number | null = null; count.toFixed(81); | let count: number | null = null; if(count!==null) count.toFixed(81); | Null check. | TypeScript |
<person><desc>result</desc><desc>15</desc></person | <person><desc>result</desc><desc>15</desc></person> | Add closing >. | XML |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
let z: Int = 'data' | let z: String = 'data' | Fix type. | Swift |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
let temp = 19; | let temp = 19; | Correct. | JavaScript |
let result = 'message' | let result = "message" | Double quotes. | Swift |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
{{"title":"value" "id":48}} | {{"title":"value", "id":48}} | Add comma. | JSON |
def bar
puts 'message'
end | def bar
puts 'message'
end | Correct. | Ruby |
function test(index)
print(index)
end | function test(index)
print(index)
end | Correct. | Lua |
if data = 26: | if data == 26: | Use == for comparison. | Python |
if [ $foo = 75 ]; then | if [ "$foo" = 75 ]; then | Quote variable. | Shell |
WHERE email = '15' | WHERE email = 15 | Don't quote integer. | SQL |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(93); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(93); | Correct. | Node.js |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
disp('value') | disp('value') | Correct. | MATLAB |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
count == '54' | count === 54 | Use strict equality. | JavaScript |
int temp = 'message'; | String temp = 'message'; | Type mismatch. | Dart |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
h1 {{ font-size:24px color:#333; }} | h1 {{ font-size:24px; color:#333; }} | Add semicolon. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
if ($num = 52) | if ($num == 52) | Use ==. | Perl |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
items[51] | if items.indices.contains(51) {{ items[51] }} | Check index. | Swift |
else
print('message') | else:
print('message') | Colon after else. | Python |
SELECT * FROM products WHRE age=80; | SELECT * FROM products WHERE age=80; | Fix WHERE. | SQL |
for b in range(72)
print(b) | for b in range(72):
print(b) | Colon after for. | Python |
let mut item=44; let r1=&mut item; let r2=&mut item; | let mut item=44; {{ let r1=&mut item; }} let r2=&mut item; | Only one mutable borrow. | Rust |
UPDATE users SET id='output' WHERE email=87 | UPDATE users SET id='output' WHERE email=87; | Add semicolon. | SQL |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
object Item {{ def main(args: Array[String]) = println("output") }} | object Item {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
val temp: Int = 'output' | val temp: String = 'output' | Fix type. | Kotlin |
<p>output <b>test</p></b> | <p>output <b>test</b></p> | Nest properly. | HTML |
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 |
'value' + 33 | 'value' + 33.to_s | Convert int. | Ruby |
if ($c = 50) {{}} | if ($c -eq 50) {{}} | Use -eq. | PowerShell |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
for (int i=0; i<51; i++) {{}} | for (int i=0; i<51; i++) {{}} | Correct. | Java |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
$data[75] | if ($data.Count -gt 75) {{ $data[75] }} | Check bounds. | PowerShell |
y = world | y = 'world' | Quote strings. | Python |
if (data = 43) {{}} | if (data == 43) {{}} | Use ==. | Java |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
DELETE FROM items WHERE id=51 | DELETE FROM items WHERE id=51; | Add semicolon. | SQL |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<hr></hr> | <hr> | Self-closing. | HTML |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<input type='text' value='info'> | <input type='text' value='info' name='title'> | Add name attribute. | HTML |
<br></br> | <br> | Self-closing. | HTML |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
let v=vec![63,18,58]; let primary=&v[0]; v.push(51); | let mut v=vec![63,18,58]; let primary=v[0]; v.push(51); | Copy instead of reference. | Rust |
$arr[65] = 5; | if (isset($arr[65])) $arr[65] = 5; | Check existence. | PHP |
1result = 10 | result1 = 10 | Variable cannot start with digit. | Python |
print('test') | print('test') | Correct. | R |
match result {{ 1 => {{}} }} | match result {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
data = 20 | data=20 | No spaces. | Shell |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
my @arr = (21,52,4); | my @arr = (21,52,4); | Correct. | Perl |
data.forEach(function(num) {{ console.log(num); }}) | data.forEach((num) => {{ console.log(num); }}) | Arrow functions are cleaner. | JavaScript |
jwt.sign({{id:49}}, 'token'); | jwt.sign({{id:49}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
if (data = 7) {{}} | if (data == 7) {{}} | Use ==. | Kotlin |
def process(b):
return b + 1 | def process(b):
return b + 1 | Correct. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
{{'name':59, 'status' 72}} | {{'name':59, 'status':72}} | Colon missing. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
y > 8 & x < 59 | y > 8 and x < 59 | Use 'and' not '&'. | Python |
'world' + 94 | 'world' + str(94) | Can't add int to string. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
var x = 13; | var x = 13; | Correct. | Dart |
function baz() {{
return
{{key:'hello'}}
}} | function baz() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
print 'value' | print('value') | print needs parentheses. | Python |
x := 98 | x := 98 | Correct. | Go |
if x = 77 then
print('test')
end | if x == 77 then
print('test')
end | Use ==. | Lua |
int[] data = new int[16];
data[16] = 5; | int[] data = new int[16];
if (16 < data.length) data[16] = 5; | Check bounds. | Java |
String count = 'value'; | String count = "value"; | Double quotes. | Java |
if (bar = 7) | if (bar == 7) | Use ==. | C++ |
SELECT id status FROM orders; | SELECT id, status FROM orders; | Add comma. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.