python zip function

Solutions on MaxInterview for python zip function by the best coders in the world

showing results for - "python zip function"
Serena
22 Jun 2020
1>>> x = [1, 2, 3]
2>>> y = [4, 5, 6]
3>>> zipped = zip(x, y)
4>>> list(zipped)
5[(1, 4), (2, 5), (3, 6)]
6>>> x2, y2 = zip(*zip(x, y))
7>>> x == list(x2) and y == list(y2)
8True
Roberto
11 Nov 2019
1first_name = ['John', 'James', 'Jennifer']
2last_name  = ['Doe', 'Bond', 'Smith']
3 
4students = zip(first_name, last_name)
5 
6print(list(students))
7 
8# Output:
9# [('John', 'Doe'), ('James', 'Bond'), ('Jennifer', 'Smith')]