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

I'm unable to set this shopping value between 100 and 199. can someone help with this issue.

shopping = float(input("How much did your shopping cost ")) if shopping >= float(200.00): print("shopping price is {} with ten percent off".format(shopping /10 * 9 )) if shopping <= (100,199) print("your total is {} with a 5 percent discount".format(shopping /20 * 19))

1 Answer

You are missing a colon after if shopping <= (100,199), and comparing the float shopping to the tuple (100, 199) using <= gives a type error. You could change the line to if shopping in range(100, 200): or if shopping >= 100 and shopping <= 199:. These would be true for values of shopping such as 100.0 and 199.0, and false for values such as 99.99 and 199.01.

If you wanted the condition to be true for all values for shopping greater than or equal to 100 and strictly less than 200, you could change the second if statement to elif shopping >= 100:, since the first if statement checks if shopping is greater than or equal to 200.