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 trialSzymon Dabrowski
2,207 PointsNot a Question but Praise
I'd like to thank Treehouse and Craig Dennis for this course. I have learnt many useful skills with the way content is provided on treehouse. I wanted to share my experience with others to give my perspective on how I completed the basics.
In fact to fully understand everything in regards to the Python Basics I have had to watch the whole course twice. However, the second time round was not just simply watching the course but it had a purpose instead. I have seen that it does not just take python knowledge to create something but it can be many different things.
Besides the Python Basics Course I have also completed: Bonus series: How to learn, Workshops on how to use Coda, Introduction to the Terminal, Introduction to Git, GitHub Basics, Scrum Basics. And, besides treehouse I have also spent lots of time researching, making notes with Coda, even more time reading concepts, documentation and trying it myself. Thanks to the how to learn bonus content I have implemented the pomodoro technique which has really helped me excel in my learning. I have also just started to read through the Python crash course V2 to work through everything again to reinforce my memory (it is very important to practice what you know so that you don't forget) and, then take up on some fun projects like making a space invaders game.
So if you are learning the basics. Please never give up and keep on going. Eventually you will get there. I always like to compare learning how to code with learning how to skateboard. Practice makes perfect and if you never give up you will eventually reach your goal. Took me months to learn an ollie (jumping on skateboard) but when I finally done it it felt amazing. And you can apply this to anything in life.
This is my slight different version of the code compared to Craig because I did not like how the error was handled with "Would you like to proceed y/n". I have implemented another while loop in there so that if someone makes an error typing it does not kick them all the way back up to the start of the first while loop but instead will give them a friendly error and ask again if they want to proceed. And, I have also added some basic input to ask for credit card information just for fun and practice.
I have also used this project as an opportunity to practice using git and github which I highly recommend to you. If you would like to see how I practiced this is the repository: https://github.com/UP814818/ticket_master
(I recommend doing the introduction to terminal first then, introduction to git course then github basics)
SERVICE_CHARGE = 2
TICKET_PRICE = 10
tickets_remaining = 100
def calculate_price(number_of_tickets):
return (number_of_tickets * TICKET_PRICE) + SERVICE_CHARGE
while tickets_remaining >= 1:
print("There are {} tickets remaining".format(tickets_remaining))
user_name = str(input("What is your name? "))
try:
num_tickets = int(input("{}, how many tickets would you like to purchase? "
.format(user_name)))
if num_tickets > tickets_remaining:
raise ValueError("There are only {} tickets remaining"
.format(tickets_remaining))
except ValueError as err:
print("Oh no, we ran into an issue. {}. Please Try again"
.format(err))
else:
total_due = calculate_price(num_tickets)
print("Total price due is ${}".format(total_due))
permission = str(input("Would you like to proceed {}? (Y/N): "
.format(user_name)))
while permission != "y" or "n":
if permission.lower() == "y":
#TODO: Error Handling for entering card information.
credit_card = str(input("{}, Please enter your credit card number: "
.format(user_name)))
card_exp = str(input("Please enter the card's Expiry Date: "))
card_cvv = str(input("And, finally enter your CVV: "))
print("Processing...")
print("SOLD!")
tickets_remaining -= num_tickets
break
elif permission.lower() == "n":
print("Thank you for your interest {}".format(user_name))
break
else:
print("That's incorrect. Please answer with either y or n")
permission = str(input("Would you like to proceed {}? (Y/N): "
.format(user_name)))
print("Sorry the tickets are all sold out!!! :-(")
Szymon Dabrowski
2,207 PointsSteven Parker. I think Craig has noticed as I seen he has given me a star on github :)
Takyi Akwah
2,977 PointsI was also thinking there must be a way to stop the program from restarting if the wrong input is entered. I was happy to see your code had accounted for this and implemented it into my own code. Thanks for the share. Much appreciated.
1 Answer
heebers
Python Development Techdegree Student 1,835 PointsAgreed. Just finished course one. I have been supplementing with my own books and medium articles but Craig’s teaching style is really effective for implementing the knowledge into actual skills (for me at least). Feel like I have a solid foundation in continuing to develop my python skills now (without the support of a formal bootcamp program — which is what I was looking for before finding out about Treehouse).
Thanks Treehouse team!
Steven Parker
231,261 PointsSteven Parker
231,261 PointsI understand that Craig Dennis hasn't been on staff since 2018, but perhaps by tagging him here he may find this posting if he still checks the forum now and then.