May 2021 1 74 Report
Can you help with this code? It won’t run.?

my_list = []

def grocerylist():

.....print("Your grocery list contains: ")

print(" ")

for item in my_list:

.....print(item)

.... print (" ")

.....print ("1 = add item to list")

.... print ("3 = remove item")

... print ("4 = reverse list")

....print ("5 = print out some of the list")

.... print ("6 = sort into alphabetical order")

.....print ("9 = quit")

.....choice = raw_input("Enter the option you want to continue with ")

if "choice" == 1:

....print("You chose option 1")

.... additem = raw_input("Enter an item you want to add: ")

.....my_list.append(additem)

if "choice" == 3:

....print("You chose option 3")

.....take_away = int(input("Which item would you like to delete? (enter a number)")

....del my_list([take_away])

if "choice" == 4:

.... print("You chose option 4")

.....print("This will reverse your list")

.....my_list.reverse()

if "choice" == 5:

.....print("You chose option 5")

......end = raw_input("Which item should we end at? (Insert a number)")

for printlist in range(end):

....print (my_list[printlist])

if "choice" == 6:

....print("You chose option 6")

... my_list.sort()

if "choice" ==9:

....print("You have chosen to quit the program")

....quit

else:

.....print ("Try again")

grocerylist()

Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments


Helpful Social

Copyright © 2024 1QUIZZ.COM - All rights reserved.