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 Branch and Loop

I cannot get the tickets to subtract! Honestly, so FRUSTRATED@!!!

I am trying to get the remaining tickets to print. What am I doing so wrong? Honestly, I want to GIVE UP

Abdullah Al-Romaihi
Abdullah Al-Romaihi
2,172 Points
tickets_remaining = tickets_remaining - tickets_needed

tickets_needed is the prompt that the user replies to

4 Answers

Steven Parker
Steven Parker
231,269 Points

You'd need to post more of the code to be sure, but if "tickets_needed" is assigned from an "input" it would be a string. You'd need to convert it to a number before you could subtract it.

Automatically python defaults to a string datatype and this is why you need to simply convert tickets_needed:

tickets_remaining = tickets_remaining - int(tickets_needed)

Why do I keep losing my temper over my code not being right???? Am I crazy or what!

Coding can definitely make you rethink your life choices, but its the ride that makes it enjoyable. Take a break even if it is for a day or two and come back to it. I have been sketching on my ipad with procreate to help take the edge off. Dont give up ever you will be much happier once you complete your goal.

sorry I love coding but when I keep getting it wrong I lose it...I don't seem to have patience with it. So after following the suggestions here I do believe I have finally nailed it to the wall...thx

Steven Parker
Steven Parker
231,269 Points

Perhaps having lots of opportunity to practice having patience with yourself will be a bonus benefit of learning programming. :wink: