for i,j in zip(a,b):
print (i, j)
names = [ ' tim ', ' joe ' , ' billy ', ' sally ' ]
ages = [ 21, 19, 18, 43 ]
eye_color = [ ' blue ' , ' brown ' , ' brown ' , ' green ']
print(list(zip(names, ages, eye_color)))
for name, age in zip( names, ages ) :
if age > 20 :
print(name)
"""
Joining any number of iterables by combining elements in order
- Iterables include: str, list, tuples, dict etc...
- No error will be incurred if you zip lists of differing lengths,...
...it will simply zip up to the length of the shortest list
"""
lst1 = [1, 2, 3, 4, 5, 7]
lst2 = "mangos"
lst3 = (3.1, 5.4, 0.2, 23.2, 8.88, 898)
lst4 = {"Car": "Mercedes Benz", "Location": "Eiffel Tower", "Organism": "Tardigrade"}
result = list(zip(lst1, lst2, lst3, lst4.keys()))
print(result)
d = {'k1': 1, 'k2': 2}
d = {'k1': 1, 'k2': 2}
d.update([('k3', 3), ('k3', 300)])
print(d)
d = {'k1': 1, 'k2': 2}
keys = ['k3', 'k3']
values = [3, 300]
d.update(zip(keys, values))
print(d)