Programming Languages
Python
Subjective
Sep 30, 2025
Explain Python's `zip()` function with practical examples.
Detailed Explanation
names = ["Alice", "Bob", "Charlie"]\nages = [25, 30, 35]\n\n# Combine lists:\nfor name, age in zip(names, ages):\n print(f"{name} is {age} years old")\n\n# Create dictionary:\npeople = dict(zip(names, ages))\n\n# Unzip: names, ages = zip(*people.items())
Discussion (0)
No comments yet. Be the first to share your thoughts!
Share Your Thoughts