Question: Can someone help me correct my code where the ? ? ? are? # candies LIST on startup candies = [ ' M&Ms ' ,
Can someone help me correct my code where the are?
# candies LIST on startup
candies M&Ms'Snickers','Twizzlers','KitKat','Butterfinger','Twix',
'Skittles','Starburst','Smarties','Nerds','SweetTarts','Rolo'
# DISPLAY the program HEADER.
def displaybanner:
print
print
print Candy Program
print
# DISPLAY the user MENU options.
def displaymenu:
print
Menu Options:"
print
print Display the list of candies"
print Display how many candies are in the list"
print Return the index number of a queried candy"
print Search the list for a Candy and display search results"
print Add a candy to the front of the list"
print Add a candy to the end of the list"
print Add a candy to the nd to the end of the list"
print Add a candy to the end of the list only if it does not exist in the
list"
print Remove a candy from the list"
print Sort the candies list ascending order
print Sort the candies list descending order
print Display the first and last candies in the sorted ascending list"
print Display the candies in the sorted ascending order list A thru L
print Display the candies in the sorted ascending order list M thru Z
print ExitEnd the program"
# Display all candies in the candies list.
def displaycandies:
print
Candy List
printindex
print
# Display how many candies are available in the list.
def numberofcandies:
numcandies
printf
There are numcandies candies in the list."
# FIND the index number list position of a queried candy.
def findcandyindex:
candy input
Enter the candy to find its index:
candy candy.???
if candy in candies:
index
printf
The Candy candy is found at index: index
else:
printf
candy is not found in the list."
# SEARCH the candies list for for a specific candy.
def searchlist:
candy input
Enter the Name to search:
candy candy.title
printf
candy is in the list."
else:
printf
candy is not in this list"
# ADD a new candy to the front of the list.
def addtofront:
candy input
Enter the Candy to add:
candy candy.capitalize
printf
candy was added to the front of the list."
displaycandies
# ADD a new candy to the end of the list.
def addtoend:
candy input
Enter the Candy to add:
candy candy.capitalize
printf
candy was added to the end of the list.
displaycandies
# ADD a new candy second to the last of the list
def secondtolast:
candy input
Enter the Candy to add:
candy candy.capitalize
printf
candy was added second to the last of the list.
displaycandies
# ADD a candy only if it is not already on the list
def doesnotexist:
newcandy inputEnter the new Candy to add:
newcandy newcandy.capitalize
if
candies.appendnewcandy
printf
newcandy was added to the end of the list."
displaycandies
else:
printf
newcandy already exists in the list."
# REMOVE a candy from the list.
def removeentry:
candy input
Enter the candy to remove:
candy candy.capitalize
if candy in candies:
printf
candywas removed from the list."
displaycandies
else:
printf
candy was not found in the list."
# SORT the candies list in alphabetical order ASCENDING order
def sortcandies:
print
The candies are organized in ascending order."
displaycandies
# SORT the candies list in Descending order.
def sortdescendingcandies:
print
The candies are organized in descending order."
displaycandies
# SORT the list and then gets the first and last candy on the list
def firstandlastcandies:
candies.sort
first
last
printf
The first candy in the list is first and the'
f last candy in the list is last
# DISPLAY the sorted candies on the list from A through L
def displaysortedbylettersAL:
candies.sort
print
Candies from A through L
for candy in candies:
if
printcandy
print
# Display the sorted candies on the list from M through Z
def displaysortedbyletterMZ:
print
Candies from M through z
for candy in candies:
if
printcandy
print
# EXIT the program with a goodbye message.
def exitprogram:
print
Exiting the Candy organizing Program. Goodbye!"
# ASK user to a ENTER a NUMBER from in the MENU.
def main:
displaybanner
Continue 'Yes'
while Continue 'Yes':
displaymenu
choice input
Enter your choice :
if choice :
displaycandies
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
