add info n zip

This commit is contained in:
Rohit Tanwar
2018-01-21 11:26:15 +05:30
parent 59fcc51872
commit 862327ceed
3 changed files with 5 additions and 0 deletions

View File

@ -318,6 +318,8 @@ spread([1,2,3,[4,5,6],[7],8,9]) # [1,2,3,4,5,6,7,8,9]
``` ```
### zip ### zip
:information_source: Already implemented via `itertools.zip_longest()`
Creates a list of elements, grouped based on the position in the original lists. Creates a list of elements, grouped based on the position in the original lists.
Use `max` combined with `list comprehension` to get the length of the longest list in the arguments. Loops for `max_length` times grouping elements. If lengths of `lists` vary `fill_value` is used. By default `fill_value` is `None`. Use `max` combined with `list comprehension` to get the length of the longest list in the arguments. Loops for `max_length` times grouping elements. If lengths of `lists` vary `fill_value` is used. By default `fill_value` is `None`.

View File

@ -6,6 +6,7 @@ files = os.listdir('snippets')
codeRe = "```\s*python([\s\S]*?)```" codeRe = "```\s*python([\s\S]*?)```"
for file in files: for file in files:
someFile = open("snippets/" + file) someFile = open("snippets/" + file)
print(file)
fileData = someFile.read() fileData = someFile.read()
someFile.close() someFile.close()
originalCode = re.search(codeRe,fileData).group(0) originalCode = re.search(codeRe,fileData).group(0)

View File

@ -1,5 +1,7 @@
### zip ### zip
:information_source: Already implemented via `itertools.zip_longest()`
Creates a list of elements, grouped based on the position in the original lists. Creates a list of elements, grouped based on the position in the original lists.
Use `max` combined with `list comprehension` to get the length of the longest list in the arguments. Loops for `max_length` times grouping elements. If lengths of `lists` vary `fill_value` is used. By default `fill_value` is `None`. Use `max` combined with `list comprehension` to get the length of the longest list in the arguments. Loops for `max_length` times grouping elements. If lengths of `lists` vary `fill_value` is used. By default `fill_value` is `None`.