Question: Here is my code, when I run it , it seems to think that the user entered a vote that is above the total number
Here is my code, when I run it it seems to think that the user entered a vote that is above the total number of guests, and keeps prompting for a different vote.
Here is my full code
pievotes
pievotes
pievotes
guests
def getguests:
guests intinputHow many people are coming to Thanksgiving Dinner?:
print
def getpies:
pie getpie
pie getpie
pie getpie
return pie pie pie
def getpie:
pie strinputWhat is the first pie type that guests can choose from?:
return pie
def getpie:
pie strinputWhat is the second pie type that guests can choose from?:
return pie
def getpie:
pie strinputWhat is the last pie type that guests can choose from?:
return pie
def checkvotespienumvotes:
result True
if intpienumvotes intguests:
result True
else:
result False
return result
def updatepiepienumvotes, pienum:
while checkvotespienumvotes False:
printThe amount of votes for each pie may not exceed the total number of guests"
pienumvotes intinputHow many people vote for pienum :
def getvotes:
print
printThere can only be one vote per person!"
pievotes intinputHow many people vote for strpie:
updatepiepievotes, pie
pievotes intinputHow many people vote for strpie:
updatepiepievotes, pie
pievotes intinputHow many people vote for strpie:
updatepiepievotes, pie
totalvotes intpievotes intpievotes intpievotes
notvoted intguests inttotalvotes
def checktotalvotes:
if totalvotes guests:
printThe total votes match the the number of guests, it seems that everyone has cast their vote!"
elif totalvotes guests:
printThe total votes have exceeded the number of guests. Please retry."
getvotes
checkvotes
elif totalvotes guests:
printstrnotvoted people have not voted. Their votes will be added to pie
return pie notvoted
def pieorderpienumvotes, pienumorder:
if pienumvotes :
pienumorder pienumvotes
return pienumorder
elif pienumvotes :
pienumorder int
return pienumorder
def finalorder:
pieorderpievotes, pieorder
pieorderpievotes, pieorder
pieorderpievotes, pieorder
print
printHeres your pie order:"
printpie: pieorder
printpie: pieorder
printpie: pieorder
getguests
pie pie pie getpies
getvotes
checktotalvotes
pieorder
finalorder
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
