Describe how tuples can be useful with loops over lists and dictionaries, and give Python code examples. Create your own code examples. Do not copy them from the textbook or any other source.
Your descriptions and examples should include the following: the zip function, the enumerate function, and the items method.
1
Expert's answer
2021-10-17T01:45:16-0400
Tuples are immutable therefore it can be used incase of immutable data.
list1 = [1,2,3]
list2 = [4,5,6]
zipped = list(zip(list1, list2))
print('Zipped : ',zipped)
for i,j in zipped:
print(i,j)
Comments
Leave a comment