Reputation: 11
I was requested by my teacher to write a program in python which would require visitors of said attraction to insert the number of family members they are visiting with, and based off of that, have them know the admission fee. The admission fees given were $25 for anybody under 16, and 40 for anybody over 40. This is what I've got so far:
def main():
admission = 0
print("Welcome to Wally World - use this program to calculate your admission fees")
number = int(input("How many members will you be taking with you? "))
members = {}
for n in range(0,number):
age = int(input("Please enter your ages: "))
if age <= 16:
admission = 25
if age > 16:
admission = 40
main()
How would I go about grabbing said admission values and adding them all together? Thank you!
Upvotes: 1
Views: 94
Reputation: 1925
members = {}
exit()
in this case).pass
you may call your program again using main()
or exit using exit()
).Here is the working code:
def main():
admission = 0
print("Welcome to Wally World - use this program to calculate your admission fees")
number = int(input("How many members will you be taking with you? "))
if number < 0: exit()
for n in range(0,number):
age = int(input("Please enter your ages: "))
admission += (25 if age <= 16 and age > -1 else 40 if age> 16 else 0)
return admission
main()
Upvotes: 1