Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
210,424 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.

Tomasz Furmanczyk
seal-mask
.a{fill-rule:evenodd;}techdegree
Tomasz Furmanczyk
Web Development Techdegree Student 16,079 Points

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
210,424 Points

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