More Loops: All versions of foods.py in this section have avoided using for loops when printing to save space. Choose a version of foods.py, and write two for loops to print each list of foods.

Respuesta :

Limosa

Answer:

Following are the program in the Python Programming Language.

#set list type variable and initialize the elements

myPizza = ['Margarita', 'Capsicum and onion', 'Chicken']

#set variable and initialize the elements

frndPizzas = myPizza[:]

#append value in list variable

myPizza.append('Corn')

#append value in list variable

frndPizzas.append('paperica')

#print message

print("My pizzas are:")

#set the for loop and print elements of 1st list

for pizza in myPizza:

   print(pizza)

#print message

print("\nFriend's pizzas are:")

#set the for loop and print elements of 2st list

for frndsPizza in frndPizzas:

   print(frndsPizza)

Output:

My pizzas are:                                                                                                                  

Margarita                                                                                                                       Capsicum and onion                                                                                                               Chicken                                                                                                                          Corn                                                                                                                                                                                                                                                        

Friend's pizzas are:                                                                                                            

Margarita                                                                                                                      Capsicum and onion                                                                                                              Chicken                                                                                                                         paperica    

Explanation:

Following are the description of the program:

  • Set a list data type variable that is 'myPizza' and initializes elements in it.
  • Set another list data type variable that is 'frndPizzas' and initializes elements in it.
  • Append one-one element in both of the list data type variables.
  • Set the for loops to print the elements of both list data type variables.