Travis build: 145

This commit is contained in:
30secondsofcode
2019-10-08 06:41:17 +00:00
parent 0aa8757464
commit b65a89ed00
3 changed files with 57 additions and 0 deletions

View File

@ -39,6 +39,7 @@
* [`every`](#every)
* [`every_nth`](#every_nth)
* [`filter_non_unique`](#filter_non_unique)
* [`filter_unique`](#filter_unique)
* [`flatten`](#flatten)
* [`group_by`](#group_by)
* [`has_duplicates`](#has_duplicates)
@ -478,6 +479,27 @@ filter_non_unique([1, 2, 2, 3, 4, 4, 5]) # [1, 3, 5]
<br>[⬆ Back to top](#contents)
### filter_unique
Filters out the unique values in a list.
Use list comprehension and `list.count()` to create a list containing only the non-unique values.
```py
def filter_unique(lst):
return [x for x in set(item for item in lst if lst.count(item) > 1)]
```
<details>
<summary>Examples</summary>
```py
filter_unique([1, 2, 2, 3, 4, 4, 5]) # [2, 4]
```
</details>
<br>[⬆ Back to top](#contents)
### flatten
Flattens a list of lists once.

View File

@ -402,6 +402,21 @@
"hash": "05679ae115d276830ec769a04b0800d92eabc6a09678fc1a9cf6013c813cc650"
}
},
{
"id": "filter_unique",
"type": "snippetListing",
"title": "filter_unique",
"attributes": {
"text": "Filters out the unique values in a list.\n\nUse list comprehension and `list.count()` to create a list containing only the non-unique values.\n\n",
"tags": [
"list",
"beginner"
]
},
"meta": {
"hash": "174c62134c81e139aa9d0b31f46c684b5edd4c52e721136d586d435058e19288"
}
},
{
"id": "flatten",
"type": "snippetListing",

View File

@ -532,6 +532,26 @@
"hash": "05679ae115d276830ec769a04b0800d92eabc6a09678fc1a9cf6013c813cc650"
}
},
{
"id": "filter_unique",
"title": "filter_unique",
"type": "snippet",
"attributes": {
"fileName": "filter_unique.md",
"text": "Filters out the unique values in a list.\n\nUse list comprehension and `list.count()` to create a list containing only the non-unique values.\n\n",
"codeBlocks": {
"code": "def filter_unique(lst):\n return [x for x in set(item for item in lst if lst.count(item) > 1)]",
"example": "filter_unique([1, 2, 2, 3, 4, 4, 5]) # [2, 4]"
},
"tags": [
"list",
"beginner"
]
},
"meta": {
"hash": "174c62134c81e139aa9d0b31f46c684b5edd4c52e721136d586d435058e19288"
}
},
{
"id": "flatten",
"title": "flatten",