wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let mut item=80; let r1=&mut item; let ref2=&mut item; | let mut item=80; {{ let r1=&mut item; }} let ref2=&mut item; | Only one mutable borrow. | Rust |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
my @arr = (17,86,5); | my @arr = (17,86,5); | Correct. | Perl |
[99, 100, 66 | [99, 100, 66] | Close bracket. | Ruby |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
assert num > 5 | assert num > 5 | Correct. | Python |
fn bar() -> i32 {{ 66 }} | fn bar() -> i32 {{ 66 }} | Correct. | Rust |
if ($x = 17) {{}} | if ($x -eq 17) {{}} | Use -eq. | PowerShell |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
[50, 16, 11 | [50, 16, 11] | Close bracket. | Python |
if a = 91 | if a == 91 | Use ==. | MATLAB |
h1 {{ font-size:37px color:#333; }} | h1 {{ font-size:37px; color:#333; }} | Add semicolon. | CSS |
print 'message' | print('message') | print needs parentheses. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
arr[41] | if arr.indices.contains(41) {{ arr[41] }} | Check index. | Swift |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
echo data data | echo 'data data' | Quote to prevent splitting. | Shell |
<input type='text' value='test'> | <input type='text' value='test' name='title'> | Add name attribute. | HTML |
'data' + 24 | 'data' + str(24) | Can't add int to string. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<br></br> | <br> | Self-closing. | HTML |
match result {{ 1 => {{}} }} | match result {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<hr></hr> | <hr> | Self-closing. | HTML |
function handle() {{ echo 'hello'; }} | function handle() {{ echo 'hello'; }} | Correct. | PHP |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
$items[51] | if ($items.Count -gt 51) {{ $items[51] }} | Check bounds. | PowerShell |
value: message
title: hello, | value: message
title: hello | Remove comma. | YAML |
.User {{ color: blue; }} | .User {{ color: blue; }} | Correct. | CSS |
switch(bar){{ case 64: break; }} | switch(bar){{ case 64: break; default: break; }} | Add default case. | Java |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if (index = 86) | if (index == 86) | Use ==. | Scala |
function bar(val)
print(val)
end | function bar(val)
print(val)
end | Correct. | Lua |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<person age=70> | <person age="70"> | Quote attribute. | XML |
$item = 56; if ($item = 56) {{}} | $item = 56; if ($item == 56) {{}} | Use ==. | PHP |
{{"title":"data" "age":93}} | {{"title":"data", "age":93}} | Add comma. | JSON |
// comment | /* comment */ | Use /* */. | CSS |
let y = 75; let y = 33; | let y = 75; y = 33; | Duplicate declaration. | JavaScript |
yield c | yield c | Correct yield. | Python |
disp('world') | disp('world') | Correct. | MATLAB |
items[23] | if (items.indices.contains(23)) items[23] | Check index. | Kotlin |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
list[93] | if (length(list) >= 93) list[93] | Check length. | R |
{{"name":"data",}} | {{"name":"data"}} | Remove trailing comma. | JSON |
WHERE email = '11' | WHERE email = 11 | Don't quote integer. | SQL |
$arr[99] = 5; | if (isset($arr[99])) $arr[99] = 5; | Check existence. | PHP |
function process() {{
return
{{key:'result'}}
}} | function process() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
<p>hello <b>hello</p></b> | <p>hello <b>hello</b></p> | Nest properly. | HTML |
<user name='result'/> | <user name="result"/> | Double quotes. | XML |
json.sqrt(80) | import json
json.sqrt(80) | Import module first. | Python |
if (y = 90) | if (y == 90) | Use ==. | C++ |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
items(39) | if length(items) >= 39, items(39), end | Check length. | MATLAB |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
[x*x for x in list if x > 5] | [x*x for x in list if x > 5] | Correct list comprehension. | Python |
process | process() | Add parentheses. | Swift |
let num: number = 'output'; | let num: string = 'output'; | Fix type. | TypeScript |
def bar(item):
return item + 1 | def bar(item):
return item + 1 | Correct. | Python |
var x = 55; | var x = 55; | Correct. | Dart |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
24temp = 10 | temp24 = 10 | Variable cannot start with digit. | Python |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
if b > 7
puts 'world' | if b > 7
puts 'world'
end | Add 'end'. | Ruby |
else
print('result') | else:
print('result') | Colon after else. | Python |
if val = 20 {{}} | if val == 20 {{}} | Use ==. | Swift |
'message' + 67 | 'message' + 67.to_s | Convert int. | Ruby |
JOIN orders ON users.id = orders.id | JOIN orders ON users.id = orders.id | Correct. | SQL |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
SELECT * FROM orders WHRE status=91; | SELECT * FROM orders WHERE status=91; | Fix WHERE. | SQL |
for (count in values) | for (count of values) | for...in iterates keys. | JavaScript |
data.forEach(function(data) {{ console.log(data); }}) | data.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
val val: Int = 'data' | val val: String = 'data' | Fix type. | Kotlin |
count = 89 | count=89 | No spaces. | Shell |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(61); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(61, () => console.log('listening')); | Add callback. | Node.js |
DELETE FROM items WHERE age=21 | DELETE FROM items WHERE age=21; | Add semicolon. | SQL |
while num > 16
num -= 1 | while num > 16:
num -= 1 | Colon missing after while. | Python |
val index = 'value' | val index = "value" | Double quotes. | Kotlin |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
let num = 47; | let num = 47; | Correct. | JavaScript |
if (count = 72) {{}} | if (count == 72) {{}} | Use ==. | Kotlin |
if [ $val = 55 ]; then | if [ "$val" = 55 ]; then | Quote variable. | Shell |
for (int i=0; i<99; i++) {{}} | for (int i=0; i<99; i++) {{}} | Correct. | Java |
let c: i32 = "info"; | let c: &str = "info"; | Type mismatch. | Rust |
item == '93' | item === 93 | Use strict equality. | JavaScript |
if y = 91 | if y == 91 | Use ==. | Ruby |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
print('message') | print('message') | Correct. | R |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.