Python Python Basics All Together Now Gather Information

MY code is not running

.

Jason Anders
Jason Anders
Treehouse Moderator 144,809 Points

Hi Samuel

You're going to need to share your code in order for others to be able to assist. Without seeing your code and the errors being thrown, it's pretty much impossible to help.

You can either share your code here using Markdown. Or share a Snapshot or your Treehouse Workspace here.

Without either of these, the Community will not be able to assist you.

:) :dizzy:

Trevor J
Trevor J
Python Web Development Techdegree Student 2,078 Points

Hi, can you post your code so we can see if there is a syntax error?

TICKET_PRICE = 10

tickets_remaining = 100

Output how many tickets are remaining using the tickets_remaining variable

print("There are {} tickets remaining.".format(tickets_remaining))

# Gather the user's name and assign it to a new variable name = input("What is your name? ")

Prompt the user by name and ask how many tickets they would like

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

Calculate the price(number of tickets multiplied by the price) and assign to a variable

amount_due = num_tickets * TICKET_PRICE

Output the price to the screen

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

3 Answers

my example code from the video. You can watch the video at the 6 minute point to see the code.

TICKET_PRICE = 10

tickets_remaining = 100

# Output tickets remaining
print("There are {} tickets remaining.".format(tickets_remaining))

#Prompt the user and ask how many tickets they like
name = input("What is your name? ")
tickets_bought = int(input("how many tickets do you want"))

# Calculate the price (number of tickets multiplied by the price)
# assign to variable

price_of_tickets = (tickets_bought * TICKET_PRICE)

# Output the price to the screen
print("The total due is ${}".format(price_of_tickets))
Marcus Grant
PRO
Marcus Grant
Pro Student 2,546 Points

Your code looks fine to me. I would check to see if your console is in Python mode or not.

If the last line in your console has three forward arrows like '>>>', type quit() to get you back to your workspace. Now, you should see 'treehouse:~/workspace$. Type python followed by the name of your file (python masterticket.py) and press enter.

Do you get any prompts in the console for you to enter your details based on the questions you specified?

Output from Workspaces

treehouse:~/workspace$ python3 sample.py
There are 100 tickets remaining.
What is your name? mike
how many tickets do you want3
The total due is $30
treehouse:~/workspace