Create README.md
Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com>
This commit is contained in:
parent
27e89b1ab2
commit
9fc6be8724
1 changed files with 36 additions and 0 deletions
36
python_basics/zip/README.md
Normal file
36
python_basics/zip/README.md
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
# zip
|
||||||
|
{:.no_toc}
|
||||||
|
|
||||||
|
<nav markdown="1" class="toc-class">
|
||||||
|
* TOC
|
||||||
|
{:toc}
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
## Top
|
||||||
|
|
||||||
|
Questions to [David Rotermund](mailto:davrot@uni-bremen.de)
|
||||||
|
|
||||||
|
## [zip](https://docs.python.org/3/library/functions.html#zip)
|
||||||
|
|
||||||
|
|
||||||
|
```python
|
||||||
|
zip(*iterables, strict=False)
|
||||||
|
```
|
||||||
|
|
||||||
|
> Iterate over several iterables in parallel, producing tuples with an item from each one.
|
||||||
|
|
||||||
|
```python
|
||||||
|
a = zip([1, 2, 3], ["sugar", "spice", "everything nice"])
|
||||||
|
print(a) # -> <zip object at 0x7f34987f4380>
|
||||||
|
|
||||||
|
for item in zip([1, 2, 3], ["sugar", "spice", "everything nice"]):
|
||||||
|
print(item)
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```python
|
||||||
|
(1, 'sugar')
|
||||||
|
(2, 'spice')
|
||||||
|
(3, 'everything nice')
|
||||||
|
```
|
Loading…
Reference in a new issue