zip() is a Python built in that lets you combine two or more iterable objects like lists into groups of tuples. zip() is a convenient way of grouping data in multiple lists together in an elementwise fashion.
*Note: Longitude is misspelled in the video! I corrected this in the code below.*
Code used in the video:
# Use zip() to combine iterables like lists into tuples (elementwise)
# Useful for making separate lists into tuples
latitude = [4,5,6,4,6,2,4,5,6]
longitude = [6,3,6,3,4,5,6,8,5]
[*zip(latitude, longitude)]
# Can operate on more than 2 inputs
altitude = [12,41,15,16,15,23,14,51,61]
[*zip(latitude, longitude, altitude)]
# Zip will only continue up to the length of the shortest input
short = [1,2,3,4]
long = [1,2,3,4,5,6,7,8]
[*zip(short, long)]
# If you want to keep all items, use
from itertools import zip_longest
short = [1,2,3,4]
long = [1,2,3,4,5,6,7,8]
[*zip_longest(short, long, fillvalue=None)]
* Note: YouTube does not allow greater than or less than symbols i
5 views
13
8
4 weeks ago 00:05:17 1
The Ultimate Email Extractor in 2024: YellowPages Scraper 🌎
4 weeks ago 00:03:55 1
Pokemon GO Joystick, Teleport, Auto Walk - How to Get Pokemon GO Spoofer iOS & Android 2024 FREE
4 weeks ago 00:12:05 1
ZenBusiness Review 2024: What Makes It Stand Out?
1 month ago 00:04:14 1
Paramore: Decode [OFFICIAL VIDEO]
1 month ago 02:01:18 1
Half-Life 2: 20th Anniversary Documentary
1 month ago 00:36:24 3
Best of the Worst Trivia!
1 month ago 00:03:07 1
Delta Executor iOS iPhone Android NO KEY - Roblox Script Executor Mobile NEW UPDATE 2024
1 month ago 00:03:04 1
Bach, Organ Sonata No. 4 in E minor (BWV 528) 3. Un poco Allegro.
1 month ago 00:04:49 1
Play To Earn🔥This New Play to Earn Game is About to Make a Lot of People RICH
1 month ago 00:03:04 1
Arena Of Valor Hack - How to Get Unlimited Vouchers! iOS Android