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
pie_1_votes =0
pie_2_votes =0
pie_3_votes =0
guests =0
def get_guests():
guests = int(input("How many people are coming to Thanksgiving Dinner?: "))
print("")
def get_pies():
pie_1= get_pie_1()
pie_2= get_pie_2()
pie_3= get_pie_3()
return pie_1, pie_2, pie_3
def get_pie_1():
pie_1= str(input("What is the first pie type that guests can choose from?: "))
return pie_1
def get_pie_2():
pie_2= str(input("What is the second pie type that guests can choose from?: "))
return pie_2
def get_pie_3():
pie_3= str(input("What is the last pie type that guests can choose from?: "))
return pie_3
def check_votes(pie_num_votes):
result = True
if int(pie_num_votes)<= int(guests):
result = True
else:
result = False
return result
def update_pie(pie_num_votes, pie_num):
while check_votes(pie_num_votes)== False:
print("The amount of votes for each pie may not exceed the total number of guests")
pie_num_votes = int(input("How many people vote for "+ pie_num +"?: "))
def get_votes():
print("")
print("There can only be one vote per person!")
pie_1_votes = int(input("How many people vote for "+ str(pie_1)+"?: "))
update_pie(pie_1_votes, pie_1)
pie_2_votes = int(input("How many people vote for "+ str(pie_2)+"?: "))
update_pie(pie_2_votes, pie_2)
pie_3_votes = int(input("How many people vote for "+ str(pie_3)+"?: "))
update_pie(pie_3_votes, pie_3)
total_votes = int(pie_1_votes)+ int(pie_2_votes)+ int(pie_3_votes)
not_voted = int(guests)- int(total_votes)
def check_total_votes():
if total_votes == guests:
print("The total votes match the the number of guests, it seems that everyone has cast their vote!")
elif total_votes > guests:
print("The total votes have exceeded the number of guests. Please retry.")
get_votes()
check_votes()
elif total_votes < guests:
print(str(not_voted)+" people have not voted. Their votes will be added to "+ pie_1)
return pie_1+ not_voted
def pie_order(pie_num_votes, pie_num_order):
if pie_num_votes >3:
pie_num_order = pie_num_votes//8
return pie_num_order
elif pie_num_votes <=3:
pie_num_order = int(0)
return pie_num_order
def final_order():
pie_order(pie_1_votes, pie_1_order)
pie_order(pie_2_votes, pie_2_order)
pie_order(pie_3_votes, pie_3_order)
print("----------------------")
print("Here's your pie order:")
print(pie_1+": "+ pie_1_order)
print(pie_2+": "+ pie_2_order)
print(pie_3+": "+ pie_3_order)
get_guests()
pie_1, pie_2, pie_3= get_pies()
get_votes()
check_total_votes()
pie_order()
final_order()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!