Skip to content

Commit

Permalink
Comprehensions
Browse files Browse the repository at this point in the history
  • Loading branch information
tisnik committed Aug 7, 2023
1 parent 595e85a commit ad033e9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion docs/functional_python.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
- transformation
- Caching functions

---
---

## Practical part

Expand Down Expand Up @@ -287,6 +287,7 @@ def createCounter():
#### Tuple comprehension

```python
(x*2 for x in range(11) if x%3 != 0)
```

---
Expand All @@ -305,13 +306,17 @@ lengths = [len(word) for word in words]
#### Set comprehension

```python
{x*2 for x in range(11) if x%3 != 0}

{(x, x*2) for x in range(11) if x%3 != 0}
```

---

#### Dict comprehension

```python
{x: x*2 for x in range(11) if x%3 != 0}
```

---
Expand Down

0 comments on commit ad033e9

Please sign in to comment.