Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

zip multiple lists

# zip multiple lists
names = [ ' tim ', ' joe ' , ' billy ', ' sally ' ]
ages = [ 21, 19, 18, 43 ]
eye_color = [ ' blue ' , ' brown ' , ' brown ' , ' green ']
print(list(zip(names, ages, eye_color)))  		# return list of tuples  [ ( ' tim ', 21 , ' blue ' ), ( ' joe ' , 19 , ' brown '), ( ' billy ', 18, ' brown ' ), ( ' sally ', 43 , ' green ' )]

for name, age in zip( names, ages ) :
	if age > 20 :
		print(name)				# tim sally
 
PREVIOUS NEXT
Tagged: #zip #multiple #lists
ADD COMMENT
Topic
Name
8+8 =