Python Python Basics All Together Now Gather Information

Nick Evershed
Nick Evershed
5,536 Points

Code is returning .333333 when I enter 3

TICKET_PRICE = 10

tickets_remaining = 100 tickets_remaining = (str(tickets_remaining))

Output how many tickets remaining

print("There are " + tickets_remaining + " tickets left") tickets_remaining = (int(tickets_remaining))

Gather the user's name and assign it to a new variable

name = input("Hello and welcome to Masterticket.com, what is your first name: ")

Prompt user by name and ask how many tickets

num_tickets = input("How many tickets would you like {} ".format(name)) number_tickets = int(num_tickets)

Calculate price (number of tickets * the price) and assign it to a variable

amount_due = num_tickets * TICKET_PRICE

Output the price to the screen

print("The total due is ${}".format(amount_due))

2 Answers

Oszkár Fehér
Oszkár Fehér
Treehouse Project Reviewer

Hi Nick. You converted the input to int but you still used the raw input. The issue is in this line:

amount_due = num_tickets * TICKET_PRICE

it should be:

amount_due = number_tickets * TICKET_PRICE

Because you made this in the previouse line:

number_tickets = int(num_tickets)

If you do on the input the following:

num_tickets = int(input("How many tickets would you like {} ".format(name)))

Then this line works just fine:

amount_due = num_tickets * TICKET_PRICE

I hope this helps you. Happy coding.

Nick Evershed
Nick Evershed
5,536 Points

Thanks so much, ugh just a silly little typo

Oszkár Fehér
Oszkár Fehér
Treehouse Project Reviewer

No worries, mistakes, typos are inevitable in coding, they actually teach us.

GERALD HICKS
GERALD HICKS
2,107 Points

I'm still struggling with this, should I quit and move on to another tech degree or continue with the python tech degree

Oszkár Fehér
Oszkár Fehér
Treehouse Project Reviewer

Hi Gerald. Can you show where you are stuck? Can you describe which concept you are struggling?