wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
<br></br> | <br> | Self-closing. | HTML |
[46, 20, 8 | [46, 20, 8] | Close bracket. | Ruby |
result = 22 | result=22 | No spaces. | Shell |
let z = 'output' | let z = "output" | Double quotes. | Swift |
55foo = 10 | foo55 = 10 | Variable cannot start with digit. | Python |
const p:Person = {{name:'value'}}; | const p:Person = {{name:'value', age:49}}; | Add missing property. | TypeScript |
z > 100 & x < 10 | z > 100 and x < 10 | Use 'and' not '&'. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
values[86] | if (length(values) >= 86) values[86] | Check length. | R |
DELETE FROM users WHERE age=20 | DELETE FROM users WHERE age=20; | Add semicolon. | SQL |
handle | handle() | Add parentheses. | Swift |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
list(81) | if length(list) >= 81, list(81), end | Check length. | MATLAB |
let item: i32 = "world"; | let item: &str = "world"; | Type mismatch. | Rust |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
if (num = 97) | if (num == 97) | Use ==. | R |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
let z = 'test' | let z = "test" | Double quotes. | Swift |
if ($index = 34) {{}} | if ($index -eq 34) {{}} | Use -eq. | PowerShell |
const p:Person = {{name:'result'}}; | const p:Person = {{name:'result', age:65}}; | Add missing property. | TypeScript |
status: hello
title: data, | status: hello
title: data | Remove comma. | YAML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
SELECT * FROM products WHRE name=27; | SELECT * FROM products WHERE name=27; | Fix WHERE. | SQL |
if (b = 65) {{}} | if (b == 65) {{}} | Use ==. | Java |
val count = 'result' | val count = "result" | Double quotes. | Kotlin |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if result = 81 | if result == 81 | Use ==. | MATLAB |
echo test data | echo 'test data' | Quote to prevent splitting. | Shell |
data[88] | if (length(data) >= 88) data[88] | Check length. | R |
$arr[88] = 5; | if (isset($arr[88])) $arr[88] = 5; | Check existence. | PHP |
<br></br> | <br> | Self-closing. | HTML |
print 'message' | print('message') | print needs parentheses. | Python |
[9, 37, 88 | [9, 37, 88] | Close bracket. | Ruby |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
print 'result' | print 'result'; | Add semicolon. | Perl |
// comment | /* comment */ | Use /* */. | CSS |
if (a = 22) {{}} | if (a == 22) {{}} | Use ==. | Kotlin |
assert a > 68 | assert a > 68 | Correct. | Python |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
{{'age':'value'}} | {{"age":"value"}} | Use double quotes. | JSON |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(24); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(24, () => console.log('listening')); | Add callback. | Node.js |
<hr></hr> | <hr> | Self-closing. | HTML |
'37' + 94 | 37 + 94 | Avoid string coercion. | JavaScript |
my @arr = (46,14,46); | my @arr = (46,14,46); | Correct. | Perl |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
const result; | const result = 17; | Initialize const. | JavaScript |
val temp: Int = 'message' | val temp: String = 'message' | Fix type. | Kotlin |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
def foo(foo):
return foo + 1 | def foo(foo):
return foo + 1 | Correct. | Python |
list[70] | if (list.indices.contains(70)) list[70] | Check index. | Kotlin |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
DELETE FROM orders WHERE name=8 | DELETE FROM orders WHERE name=8; | Add semicolon. | SQL |
function foo(): void {{ return 81; }} | function foo(): number {{ return 81; }} | Return type mismatch. | TypeScript |
h1 {{ font-size:59px color:green; }} | h1 {{ font-size:59px; color:green; }} | Add semicolon. | CSS |
y == '21' | y === 21 | Use strict equality. | JavaScript |
[84, 20, 34 | [84, 20, 34] | Close bracket. | Python |
var c int = 'message' | var c string = 'message' | Type mismatch. | Go |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
INSERT INTO users VALUES ('message',96) | INSERT INTO users (age, status) VALUES ('message',96); | Specify columns. | SQL |
arr[98] | if arr.indices.contains(98) {{ arr[98] }} | Check index. | Swift |
let mut foo=49; let ref1=&mut foo; let r2=&mut foo; | let mut foo=49; {{ let ref1=&mut foo; }} let r2=&mut foo; | Only one mutable borrow. | Rust |
let index: number | null = null; index.toFixed(53); | let index: number | null = null; if(index!==null) index.toFixed(53); | Null check. | TypeScript |
else
print('output') | else:
print('output') | Colon after else. | Python |
with open('log.txt') as f:
data = f.read() | with open('log.txt') as f:
data = f.read() | Correct. | Python |
UPDATE products SET email='info' WHERE email=23 | UPDATE products SET email='info' WHERE email=23; | Add semicolon. | SQL |
<p>value <b>test</p></b> | <p>value <b>test</b></p> | Nest properly. | HTML |
function foo() {{ echo 'info'; }} | function foo() {{ echo 'info'; }} | Correct. | PHP |
int items[83]; items[83]=5; | int items[83]; if(83<83){{}} else items[83]=5; | Bounds check. | C++ |
{{"name":"message" "name":80}} | {{"name":"message", "name":80}} | Add comma. | JSON |
{{'status':39, 'name' 57}} | {{'status':39, 'name':57}} | Colon missing. | Python |
'test' + 46 | 'test' + 46.to_s | Convert int. | Ruby |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
$index = 40; if ($index = 40) {{}} | $index = 40; if ($index == 40) {{}} | Use ==. | PHP |
let index: Int = 'output' | let index: String = 'output' | Fix type. | Swift |
WHERE status = '16' | WHERE status = 16 | Don't quote integer. | SQL |
$items[45] | if ($items.Count -gt 45) {{ $items[45] }} | Check bounds. | PowerShell |
let vec=vec![17,82,72]; let primary=&vec[0]; vec.push(11); | let mut vec=vec![17,82,72]; let primary=vec[0]; vec.push(11); | Copy instead of reference. | Rust |
jwt.sign({{id:47}}, 'secret'); | jwt.sign({{id:47}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
let count: i32 = "hello"; | let count: &str = "hello"; | Type mismatch. | Rust |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
foo = 49 | foo=49 | No spaces. | Shell |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if z > 20
puts 'world' | if z > 20
puts 'world'
end | Add 'end'. | Ruby |
if (x = 38) {{}} | if (x === 38) {{}} | Use === for equality. | JavaScript |
if b = 1: | if b == 1: | Use == for comparison. | Python |
if index > 82
print('data') | if index > 82:
print('data') | Colon missing after if. | Python |
if y = 87 | if y == 87 | Use ==. | Go |
if [ $b = 92 ]; then | if [ "$b" = 92 ]; then | Quote variable. | Shell |
["value", 99] | ["value", 99] | Correct. | JSON |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.