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

MY code is not running

.

Jason Anders
Jason Anders
Treehouse Moderator 145,860 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:

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
PLUS
Marcus Grant
Courses Plus 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