Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialNick Evershed
6,429 PointsCode 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))
Nick Evershed
6,429 Points$33333
2 Answers
Oszkár Fehér
Treehouse Project ReviewerHi 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
6,429 PointsThanks so much, ugh just a silly little typo
Oszkár Fehér
Treehouse Project ReviewerNo worries, mistakes, typos are inevitable in coding, they actually teach us.
GERALD HICKS
Python Development Techdegree Student 2,170 PointsI'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
Treehouse Project ReviewerHi Gerald. Can you show where you are stuck? Can you describe which concept you are struggling?
Oszkár Fehér
Treehouse Project ReviewerOszkár Fehér
Treehouse Project ReviewerFor me it gived $3333333