wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
["message", 32] | ["message", 32] | Correct. | JSON |
WHERE age = '92' | WHERE age = 92 | Don't quote integer. | SQL |
list[16] | if list.indices.contains(16) {{ list[16] }} | Check index. | Swift |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
baz | baz() | Add parentheses. | Swift |
if b = 48: | if b == 48: | Use == for comparison. | Python |
if [ $b = 18 ]; then | if [ "$b" = 18 ]; then | Quote variable. | Shell |
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 |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(5); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(5, () => console.log('listening')); | Add callback. | Node.js |
num = 43 | num=43 | No spaces. | Shell |
if ($num = 61) | if ($num == 61) | Use ==. | Perl |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let a: number | null = null; a.toFixed(19); | let a: number | null = null; if(a!==null) a.toFixed(19); | Null check. | TypeScript |
arr(40) | if length(arr) >= 40, arr(40), end | Check length. | MATLAB |
["test", 77] | ["test", 77] | Correct. | JSON |
if (temp = 92) | if (temp == 92) | Use ==. | C++ |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
for (int i=0; i<49; i++) {{}} | for (int i=0; i<49; i++) {{}} | Correct. | Java |
let val: Int = 'value' | let val: String = 'value' | Fix type. | Swift |
var a int = 'message' | var a string = 'message' | Type mismatch. | Go |
arr[84] | if arr.indices.contains(84) {{ arr[84] }} | Check index. | Swift |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
print 'world' | print('world') | print needs parentheses. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
INSERT INTO orders VALUES ('data',90) | INSERT INTO orders (id, role) VALUES ('data',90); | Specify columns. | SQL |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
let a: number | null = null; a.toFixed(86); | let a: number | null = null; if(a!==null) a.toFixed(86); | Null check. | TypeScript |
<entry name='info'/> | <entry name="info"/> | Double quotes. | XML |
// comment | /* comment */ | Use /* */. | CSS |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
function test() {{
return
{{key:'world'}}
}} | function test() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
def baz
puts 'result'
end | def baz
puts 'result'
end | Correct. | Ruby |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
if (y = 32) {{}} | if (y === 32) {{}} | Use === for equality. | JavaScript |
if (item = 47) | if (item == 47) | Use ==. | R |
let mut count=48; let r1=&mut count; let ref2=&mut count; | let mut count=48; {{ let r1=&mut count; }} let ref2=&mut count; | Only one mutable borrow. | Rust |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let result: i32 = "world"; | let result: &str = "world"; | Type mismatch. | Rust |
WHERE age = '75' | WHERE age = 75 | Don't quote integer. | SQL |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
{{'age':'data'}} | {{"age":"data"}} | Use double quotes. | JSON |
if [ $num = 10 ]; then | if [ "$num" = 10 ]; then | Quote variable. | Shell |
h1 {{ font-size:55px color:red; }} | h1 {{ font-size:55px; color:red; }} | Add semicolon. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
const z; | const z = 39; | Initialize const. | JavaScript |
for (item in data) | for (item of data) | for...in iterates keys. | JavaScript |
with open('log.txt') as file_handle:
data = file_handle.read() | with open('log.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
jwt.sign({{id:1}}, 'key'); | jwt.sign({{id:1}}, 'key', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
if bar = 26 | if bar == 26 | Use ==. | Ruby |
x := 34 | x := 34 | Correct. | Go |
const obj:Person = {{name:'result'}}; | const obj:Person = {{name:'result', age:28}}; | Add missing property. | TypeScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let v=vec![69,81,98]; let primary=&v[0]; v.push(21); | let mut v=vec![69,81,98]; let primary=v[0]; v.push(21); | Copy instead of reference. | Rust |
.Product {{ color: blue; }} | .Product {{ color: blue; }} | Correct. | CSS |
int arr[80]; arr[80]=5; | int arr[80]; if(80<80){{}} else arr[80]=5; | Bounds check. | C++ |
echo world world | echo 'world world' | Quote to prevent splitting. | Shell |
def baz(data):
return data + 1 | def baz(data):
return data + 1 | Correct. | Python |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
{{"value":"value",}} | {{"value":"value"}} | Remove trailing comma. | JSON |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
DELETE FROM users WHERE email=99 | DELETE FROM users WHERE email=99; | Add semicolon. | SQL |
z > 74 & y < 7 | z > 74 and y < 7 | Use 'and' not '&'. | Python |
def test():
print('value') | def test():
print('value') | Indent function body. | Python |
age: message
id: hello, | age: message
id: hello | Remove comma. | YAML |
class User {{ int y; }}; | class User {{ public: int y; }}; | Make public. | C++ |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<p>info <b>world</p></b> | <p>info <b>world</b></p> | Nest properly. | HTML |
function handle(count:string){{return count;}} handle(51); | function handle(count:string){{return count;}} handle('result'); | Pass correct type. | TypeScript |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
if ($x = 50) {{}} | if ($x -eq 50) {{}} | Use -eq. | PowerShell |
for temp in range(12)
print(temp) | for temp in range(12):
print(temp) | Colon after for. | Python |
print('result') | print('result') | Correct. | R |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(65); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(65, () => console.log('listening')); | Add callback. | Node.js |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
$items[40] = 5; | if (isset($items[40])) $items[40] = 5; | Check existence. | PHP |
89b = 10 | b89 = 10 | Variable cannot start with digit. | Python |
if a > 75
print('hello') | if a > 75:
print('hello') | Colon missing after if. | Python |
print 'world' | print 'world'; | Add semicolon. | Perl |
int[] data = new int[35];
data[35] = 5; | int[] data = new int[35];
if (35 < data.length) data[35] = 5; | Check bounds. | Java |
assert bar > 6 | assert bar > 6 | Correct. | Python |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
<br></br> | <br> | Self-closing. | HTML |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
if c = 44 | if c == 44 | Use ==. | Go |
if b > 38
puts 'value' | if b > 38
puts 'value'
end | Add 'end'. | Ruby |
function bar(): void {{ return 23; }} | function bar(): number {{ return 23; }} | Return type mismatch. | TypeScript |
else
print('info') | else:
print('info') | Colon after else. | Python |
UPDATE orders SET email='result' WHERE role=62 | UPDATE orders SET email='result' WHERE role=62; | Add semicolon. | SQL |
[80, 52, 73 | [80, 52, 73] | Close bracket. | Ruby |
sys.sqrt(69) | import sys
sys.sqrt(69) | Import module first. | Python |
'hello' + 52 | 'hello' + str(52) | Can't add int to string. | Python |
Product.save(); | Product.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.