How to print a list only once with a for loop

The exercise has me create a list of favorite pizzas, store it in fav_pizzas. Then asks to copy the list and store it in friend_pizzas. It says to then add a new pizza to fav_pizzas and friend_pizzas. To prove you have two different lists, print the message "My favorite pizzas are:, and then use a for loop to print the first list. Print the message "My friend’s favorite pizzas are:, and then use a for loop to print the second list.

My question is, how can I print out the message once for each element? If I use for pizza in pizzas, it will print the list 4 separate times. I know it’ll work if I specify each index like print(fav_pizzas[0]), print(fav_pizzas[1]), etc. Is there a shortcut for this?

Only if you print the list (pizzas). It won’t do that if you print the element (pizza).

Isin’t it simpler to copy and paste code (both for you and for others to help you)?

As BowlOfRed already pointed out, you wrote in Python: ‘for every item in list print list’ but you actually wanted to write: ‘for every item in list print item’.

As alternative without for-loop, one can just write:

>>> pizzas = ['margherita', 'buffalo', 'hawaiian']
>>> f'My pizzas are: {", ".join(pizzas)}'
'My pizzas are: margherita, buffalo, hawaiian'

Thanks, I forgot you could print out the variable pizza and get the result I was looking for.

Yes it is, sorry I’m used to just taking a screen capture.

I forgot that it was possible to print the item…silly mistake.

Thanks for the alternative!