Python Coding

Python Coding

6 Genius Python Hacks Using the zip() Function! ๐Ÿš€๐Ÿ

Python Coding's avatar
Python Coding
Mar 16, 2025
โˆ™ Paid

1. Pairing Elements from Two Lists

names = ["Alice", "Bob", "Charlie"]
scores = [85, 92, 78]

for name, score in zip(names, scores):
    print(f"{name}: {score}")
Alice: 85
Bob: 92
Charlie: 78

2. Unzipping Data into Separate Lists

pairs = [("Alice", 85), ("Bob", 92), ("Charlie", 78)]
names, scores = zip(*pairs)

print(names)   
print(scores)  
('Alice', 'โ€ฆ

Keep reading with a 7-day free trial

Subscribe to Python Coding to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
ยฉ 2025 clcoding ยท Privacy โˆ™ Terms โˆ™ Collection notice
Start your SubstackGet the app
Substack is the home for great culture