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 trial

Python Python Basics All Together Now Gather Information

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))

For me it gived $3333333

$33333

2 Answers

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.

Thanks so much, ugh just a silly little typo

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

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

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