Created
July 13, 2023 15:03
-
-
Save DevloperHS/cca341a21c90ca1f1c3d9530e29c933c to your computer and use it in GitHub Desktop.
How to use zip() in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # zip in python | |
| # zip function takes in multiple iterables and combines them to form a single iterable object. Let's understand its use case | |
| # 2 iterables | |
| a = [1,2,3] | |
| b = ["one", "two", "three"] | |
| # use normal - error | |
| ''' | |
| for i,j in a,b: | |
| print(i,j) | |
| ''' | |
| # use zip - works | |
| for i,j in zip(a,b): | |
| print(i,j) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment