def aquariumTicket(total = 0):
    age = input("What is your age?")
    if age < 3:
        price = 0
    elif age >=3 and age <=12:
        price = 19.5
    elif age >= 55:
        price = 21.5
    elif age >12 and age <55:
        price = 26
    print "Ticket price: $%.2f" % price
    others = raw_input("Anyone else? (y/n)")
    if others == "y":
        return aquariumTicket(total)
    else:
        print "Total price: $%.2f" % price

i have everything working except i don't know how to code for the last part of the function to calculate the total price of all the people. help please?

Total price would be a separate variable that you add price to. If you want to process more than one person at a time and give a grand total, there would have to be a while loop somewhere in the program.

As woooee said you should maintain a total price between the age inputs, and print it as the total price.

def aquariumTicket(total = 0):
    age = input("What is your age?")
    if age < 3:
        price = 0
    elif age >=3 and age <=12:
        price = 19.5
    elif age >= 55:
        price = 21.5
    elif age >12 and age <55:
        price = 26
    print "Ticket price: $%.2f" % price
    total+=price
    others = raw_input("Anyone else? (y/n)")
    if others == "y":
        return aquariumTicket(total)
    else:
        print "Total price: $%.2f" % total
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.