wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
let foo: i32 = "result"; | let foo: &str = "result"; | Type mismatch. | Rust |
test | test() | Add parentheses. | Swift |
<hr></hr> | <hr> | Self-closing. | HTML |
[98, 32, 49 | [98, 32, 49] | Close bracket. | Python |
$b = 1; if ($b = 1) {{}} | $b = 1; if ($b == 1) {{}} | Use ==. | PHP |
let s1 = String::from("test"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("test"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
function baz() {{
return
{{key:'world'}}
}} | function baz() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
[74, 38, 41 | [74, 38, 41] | Close bracket. | Ruby |
class Item {{ int temp; }}; | class Item {{ public: int temp; }}; | Make public. | C++ |
for (int i=0; i<41; i++) {{}} | for (int i=0; i<41; i++) {{}} | Correct. | Java |
let s = String::from("result"); let r=&s; s.push_str("!"); | let mut s = String::from("result"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
let data: number | null = null; data.toFixed(98); | let data: number | null = null; if(data!==null) data.toFixed(98); | Null check. | TypeScript |
let index = 'data' | let index = "data" | Double quotes. | Swift |
["message", 100] | ["message", 100] | Correct. | JSON |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
let list=vec![50,18,43]; let primary=&list[0]; list.push(76); | let mut list=vec![50,18,43]; let primary=list[0]; list.push(76); | Copy instead of reference. | Rust |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
def test():
print('hello') | def test():
print('hello') | Indent function body. | Python |
WHERE email = '10' | WHERE email = 10 | Don't quote integer. | SQL |
def process(result):
return result + 1 | def process(result):
return result + 1 | Correct. | Python |
const z; | const z = 5; | Initialize const. | JavaScript |
function bar() {{ echo 'data'; }} | function bar() {{ echo 'data'; }} | Correct. | PHP |
arr[15] | if arr.indices.contains(15) {{ arr[15] }} | Check index. | Swift |
{{"id":"output" "value":64}} | {{"id":"output", "value":64}} | Add comma. | JSON |
// comment | /* comment */ | Use /* */. | CSS |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
<note name='info'/> | <note name="info"/> | Double quotes. | XML |
print('world') | print('world') | Correct. | R |
def foo
puts 'value'
end | def foo
puts 'value'
end | Correct. | Ruby |
id: value
status: hello, | id: value
status: hello | Remove comma. | YAML |
INSERT INTO products VALUES ('hello',68) | INSERT INTO products (age, status) VALUES ('hello',68); | Specify columns. | SQL |
if count > 76
puts 'value' | if count > 76
puts 'value'
end | Add 'end'. | Ruby |
String z = 'info'; | String z = "info"; | Double quotes. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
jwt.sign({{id:97}}, 'token'); | jwt.sign({{id:97}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
for (count in data) | for (count of data) | for...in iterates keys. | JavaScript |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
'64' + 46 | 64 + 46 | Avoid string coercion. | JavaScript |
data(65) | if length(data) >= 65, data(65), end | Check length. | MATLAB |
echo hello test | echo 'hello test' | Quote to prevent splitting. | Shell |
if (item = 72) | if (item == 72) | Use ==. | C++ |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(83); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(83, () => console.log('listening')); | Add callback. | Node.js |
class Person {{ int y; }}
obj.y=5; | class Person {{ public int y; }}
obj.y=5; | Make field public. | Java |
{{'name':60, 'age' 41}} | {{'name':60, 'age':41}} | Colon missing. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
87count = 10 | count87 = 10 | Variable cannot start with digit. | Python |
h1 {{ font-size:35px color:#fff; }} | h1 {{ font-size:35px; color:#fff; }} | Add semicolon. | CSS |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
if ($foo = 95) {{}} | if ($foo -eq 95) {{}} | Use -eq. | PowerShell |
fn test() -> i32 {{ 7 }} | fn test() -> i32 {{ 7 }} | Correct. | Rust |
a = 26 | a=26 | No spaces. | Shell |
.Person {{ color: #333; }} | .Person {{ color: #333; }} | Correct. | CSS |
DELETE FROM items WHERE age=65 | DELETE FROM items WHERE age=65; | Add semicolon. | SQL |
val num = 'hello' | val num = "hello" | Double quotes. | Kotlin |
x := 56 | x := 56 | Correct. | Go |
function handle(result:string){{return result;}} handle(18); | function handle(result:string){{return result;}} handle('world'); | Pass correct type. | TypeScript |
b > 36 & x < 92 | b > 36 and x < 92 | Use 'and' not '&'. | Python |
int items[29]; items[29]=5; | int items[29]; if(29<29){{}} else items[29]=5; | Bounds check. | C++ |
index == '11' | index === 11 | Use strict equality. | JavaScript |
$values[12] = 5; | if (isset($values[12])) $values[12] = 5; | Check existence. | PHP |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<br></br> | <br> | Self-closing. | HTML |
int[] items = new int[64];
items[64] = 5; | int[] items = new int[64];
if (64 < items.length) items[64] = 5; | Check bounds. | Java |
bar | bar() | Add parentheses. | Kotlin |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if (num = 2) {{}} | if (num === 2) {{}} | Use === for equality. | JavaScript |
{{'value':'world'}} | {{"value":"world"}} | Use double quotes. | JSON |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
function bar(): void {{ return 42; }} | function bar(): number {{ return 42; }} | Return type mismatch. | TypeScript |
<entry><age>output</age><name>89</name></entry | <entry><age>output</age><name>89</name></entry> | Add closing >. | XML |
for (int i=0; i<66; i++) {{}} | for (int i=0; i<66; i++) {{}} | Correct. | Java |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
count = 65 | count=65 | No spaces. | Shell |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
if num > 22
puts 'test' | if num > 22
puts 'test'
end | Add 'end'. | Ruby |
99item = 10 | item99 = 10 | Variable cannot start with digit. | Python |
let msg = String::from("hello"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("hello"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
'data' + 99 | 'data' + 99.to_s | Convert int. | Ruby |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
list[8] | if list.indices.contains(8) {{ list[8] }} | Check index. | Swift |
function baz() {{ echo 'message'; }} | function baz() {{ echo 'message'; }} | Correct. | PHP |
<p>output <b>hello</p></b> | <p>output <b>hello</b></p> | Nest properly. | HTML |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
baz | baz() | Add parentheses. | Swift |
val x = 'data' | val x = "data" | Double quotes. | Kotlin |
let s1 = String::from("test"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("test"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
assert count > 67 | assert count > 67 | Correct. | Python |
if (count = 33) {{}} | if (count === 33) {{}} | Use === for equality. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.