names = ['John', 'Alice', 'Bob']
ages = [25, 30, 35]
combined = zip(names, ages)
for name, age in combined:
    print(f"{name} is {age} years old.")
Syntax:
	zip(iterable1, iterable2, ...)zip() stops when the shortest list is exhausted.
Convert the result to a list or any other collection type for further use. 
zip() is great for combining data, especially in scenarios like parallel iteration and data manipulation.
 

No comments:
Post a Comment