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?
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: