wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
items[43] | if items.indices.contains(43) {{ items[43] }} | Check index. | Swift |
name: result
value: hello, | name: result
value: hello | Remove comma. | YAML |
class User {{ int c; }}; | class User {{ public: int c; }}; | Make public. | C++ |
if temp = 18 | if temp == 18 | Use ==. | MATLAB |
for z in range(61)
print(z) | for z in range(61):
print(z) | Colon after for. | Python |
if item = 34: | if item == 34: | Use == for comparison. | Python |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
int items[56]; items[56]=5; | int items[56]; if(56<56){{}} else items[56]=5; | Bounds check. | C++ |
z = message | z = 'message' | Quote strings. | Python |
[67, 16, 40 | [67, 16, 40] | Close bracket. | Python |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
my @arr = (57,30,58); | my @arr = (57,30,58); | Correct. | Perl |
values[5] | if (length(values) >= 5) values[5] | Check length. | R |
let bar: i32 = "world"; | let bar: &str = "world"; | Type mismatch. | Rust |
val == '56' | val === 56 | Use strict equality. | JavaScript |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if index > 80
puts 'result' | if index > 80
puts 'result'
end | Add 'end'. | Ruby |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
print 'data' | print('data') | print needs parentheses. | Python |
WHERE email = '25' | WHERE email = 25 | Don't quote integer. | SQL |
if c = 49 | if c == 49 | Use ==. | Go |
process | process() | Add parentheses. | Kotlin |
{{"age":"result",}} | {{"age":"result"}} | Remove trailing comma. | JSON |
disp('value') | disp('value') | Correct. | MATLAB |
if ($a = 12) | if ($a == 12) | Use ==. | Perl |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
$arr[71] = 5; | if (isset($arr[71])) $arr[71] = 5; | Check existence. | PHP |
$arr[99] | if ($arr.Count -gt 99) {{ $arr[99] }} | Check bounds. | PowerShell |
os.sqrt(97) | import os
os.sqrt(97) | Import module first. | Python |
items.forEach(function(data) {{ console.log(data); }}) | items.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
// comment | /* comment */ | Use /* */. | CSS |
let mut a=13; let r1=&mut a; let ref2=&mut a; | let mut a=13; {{ let r1=&mut a; }} let ref2=&mut a; | Only one mutable borrow. | Rust |
$y = 55; if ($y = 55) {{}} | $y = 55; if ($y == 55) {{}} | Use ==. | PHP |
var item int = 'hello' | var item string = 'hello' | Type mismatch. | Go |
let text1 = String::from("output"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("output"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
<person><name>result</name><age>7</age></person | <person><name>result</name><age>7</age></person> | Add closing >. | XML |
if (foo = 24) {{}} | if (foo === 24) {{}} | Use === for equality. | JavaScript |
if (count = 19) {{}} | if (count == 19) {{}} | Use ==. | Java |
val val: Int = 'output' | val val: String = 'output' | Fix type. | Kotlin |
x := 96 | x := 96 | Correct. | Go |
def process():
print('info') | def process():
print('info') | Indent function body. | Python |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
let item: number | null = null; item.toFixed(25); | let item: number | null = null; if(item!==null) item.toFixed(25); | Null check. | TypeScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(53); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(53, () => console.log('listening')); | Add callback. | Node.js |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<p>value <b>world</p></b> | <p>value <b>world</b></p> | Nest properly. | HTML |
<user name='world'/> | <user name="world"/> | Double quotes. | XML |
jwt.sign({{id:93}}, 'secret'); | jwt.sign({{id:93}}, 'secret', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
<hr></hr> | <hr> | Self-closing. | HTML |
'hello' + 33 | 'hello' + 33.to_s | Convert int. | Ruby |
let b: number = 'value'; | let b: string = 'value'; | Fix type. | TypeScript |
String a = 'test'; | String a = "test"; | Double quotes. | Java |
<br></br> | <br> | Self-closing. | HTML |
if [ $item = 16 ]; then | if [ "$item" = 16 ]; then | Quote variable. | Shell |
assert count > 42 | assert count > 42 | Correct. | Python |
function compute(val:string){{return val;}} compute(33); | function compute(val:string){{return val;}} compute('output'); | Pass correct type. | TypeScript |
h1 {{ font-size:84px color:#333; }} | h1 {{ font-size:84px; color:#333; }} | Add semicolon. | CSS |
print('output') | print('output') | Correct. | R |
let vec=vec![41,29,49]; let first=&vec[0]; vec.push(82); | let mut vec=vec![41,29,49]; let first=vec[0]; vec.push(82); | Copy instead of reference. | Rust |
17bar = 10 | bar17 = 10 | Variable cannot start with digit. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
{{'status':'value'}} | {{"status":"value"}} | Use double quotes. | JSON |
list(86) | if length(list) >= 86, list(86), end | Check length. | MATLAB |
let data: Int = 'value' | let data: String = 'value' | Fix type. | Swift |
if (result = 86) | if (result == 86) | Use ==. | R |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
for (data in values) | for (data of values) | for...in iterates keys. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if z = 54 | if z == 54 | Use ==. | Ruby |
function test() {{ echo 'output'; }} | function test() {{ echo 'output'; }} | Correct. | PHP |
DELETE FROM products WHERE name=35 | DELETE FROM products WHERE name=35; | Add semicolon. | SQL |
{{'id':5, 'title' 49}} | {{'id':5, 'title':49}} | Colon missing. | Python |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
if (temp = 55) {{}} | if (temp == 55) {{}} | Use ==. | Kotlin |
.Item {{ color: #333; }} | .Item {{ color: #333; }} | Correct. | CSS |
else
print('output') | else:
print('output') | Colon after else. | Python |
class Product {{ int num; }}
obj.num=5; | class Product {{ public int num; }}
obj.num=5; | Make field public. | Java |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
[73, 26, 9 | [73, 26, 9] | Close bracket. | Ruby |
'message' + 10 | 'message' + str(10) | Can't add int to string. | Python |
let count = 'info' | let count = "info" | Double quotes. | Swift |
if foo > 20
print('message') | if foo > 20:
print('message') | Colon missing after if. | Python |
'5' + 13 | 5 + 13 | Avoid string coercion. | JavaScript |
{{"value":"test" "value":2}} | {{"value":"test", "value":2}} | Add comma. | JSON |
const result; | const result = 48; | Initialize const. | JavaScript |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
fn handle() -> i32 {{ 72 }} | fn handle() -> i32 {{ 72 }} | Correct. | Rust |
INSERT INTO items VALUES ('test',86) | INSERT INTO items (age, status) VALUES ('test',86); | Specify columns. | SQL |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
const obj:Person = {{name:'result'}}; | const obj:Person = {{name:'result', age:44}}; | Add missing property. | TypeScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
SELECT * FROM items WHRE age=15; | SELECT * FROM items WHERE age=15; | Fix WHERE. | SQL |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.