Просто интересно, как перебирать список кортежей и одновременно перебирать элементы внутри кортежей.
# I am able iterate over a list of tuples like this,
fruit_list = [('banana','apple','mango'),('strawberry', 'blueberry','raspberry')]
for fruit_tup in fruit_list:
print(fruit_tup)
#output:
#('banana', 'apple', 'mango')
#('strawberry', 'blueberry', 'raspberry')
# Iterate through the items inside the tuples as so,
for (item1,item2,item3) in fruit_list:
print(item1,item2,item3)
#output:
#banana apple mango
#strawberry blueberry raspberry
# This is incorrect but I tried to iterate over the tuples and the items inside the tuples as so
for fruit_tup,(item1,item2,item3) in fruit_list:
print(fruit_tup,item1,item2,item3)
#required output:
#('banana', 'apple', 'mango') banana apple mango
#('strawberry', 'blueberry', 'raspberry') strawberry blueberry raspberry
Есть идеи, как это сделать?