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 trialTerry Felder
1,738 Pointsam i overthinking or what??
so for the very first 'thing to do' was to out put the amount of tickets remaining variable. okay, so i do this,
TICKET_PRICE = 10
ticket_remaining = 100
while ticket_remaining > 0: num_tickets = int(input('How many tickets would you like?: ')) ticket_remaining -= num_tickets print('Tickets remaining: ',ticket_remaining)
any tips on not only keeping it simple, i guess HOW to keep it simple??
Terry Felder
1,738 PointsHey Steven, well i guess i was asking on tips how to understand exactly what the person is asking for me to do? the example above wants to to output the numbers of tickets left using the vairable.
well i did that but when i should have used a print statement and the format method, i created a while loop. The while loop actualy just comes later on in the project...
i guess im asking why did i go straight an make a while loop and not a simple print statement?
i don know i think i'm just confusing myself honestly i probably am overthinking it. i finished the lessson and created the project on my own..but like i said the beginning i must have just been overthinking it .....
p.s if you can follow anything i just said lol. advice and tips arethe most appreciated!
3 Answers
Ethan Goodwin
6,537 PointsYou are going to far ahead on the trello board. In this video we did not try to get all of the to-dos done. To keep it simple, just do the steps one at a time. This would be an example completing only the to-dos covered in this video:
TICKET_PRICE = 10
tickets_remaining = 100
# Gather the user's name and assign it to a new variable
username = input("Welcome to MasterTicket! What is your name? ")
# Output remaining tickets using the tickets_remaining variable
print("Hello, {}! There are {} tickets remaining.".format(username, tickets_remaining))
Miss Lucy Andresen
3,070 Pointsi think i did to def thecost(Amount): if(Amount<=0): raise ValueError("you need to ordaer 1 or more tickets") if(Amount > tickets_remanining): raise ValueError("thats to meny tikets") return (ticket_Amount*ticket_price)
print("there are {} tickets remaining".format(tickets_remanining))
get the users name
user_Name = input("what is your name? ") ticket_Amount = int(input("how meny tickets wolud you like? {} ").format(user_Name)) cost = thecost(ticket_Amount) print("it will cost {} $".format(cost)) though i still cant get raise ValueError not to go all red
Orion Foster
1,019 Pointsimport math
TICKET_PRICE = 10
tickets_remaining = 100
print("There are {} tickets left remaining.".format(tickets_remaining))
def master_ticket(TICKET_PRICE, tickets_requested):
if tickets_requested >= tickets_remaining:
raise ValueError("I'm sorry, there are only {} tickets available...".format(tickets_remaining))
return math.ceil(TICKET_PRICE * tickets_requested)
try:
name = input("What's your name? ")
tickets_requested = float(input("How many tickets would you like? "))
amount_due = master_ticket(TICKET_PRICE, tickets_requested)
except ValueError as err:
print("Oh no! That is not a valid value. Try again...")
print("({})".format(err))
else:
print("That will be ${}".format(amount_due))
This is what I did... I thought I might be overthinking it too, but it works.
Steven Parker
231,248 PointsSteven Parker
231,248 PointsI"m not sure what you're asking. Can you rephrase and elaborate a bit?