PyData Careers
20.8K subscribers
205 photos
4 videos
26 files
351 links
Python Data Science jobs, interview tips, and career insights for aspiring professionals.

Admin: @HusseinSheikho || @Hussein_Sheikho
Download Telegram
Combine multiple iterables into one with zip()!

Instead of:
names = ['Alice', 'Bob', 'Charlie']
ages = [30, 24, 35]
for i in range(len(names)):
print(f"{names[i]} is {ages[i]} years old.")


Use zip() for a cleaner and more Pythonic approach:
names = ['Alice', 'Bob', 'Charlie']
ages = [30, 24, 35]
for name, age in zip(names, ages):
print(f"{name} is {age} years old.")

zip() stops when the shortest iterable is exhausted. Perfect for parallel iteration!

#PythonTip #ZipFunction #Iterators #PythonicCode

---
By: @DataScienceQ