Answer to Question #252361 in Python for Raymond Ekwubiri

Question #252361
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)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS