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 Types and Branching Comparing values

Why is this not if age <= 13 ?

I don't understand how you don't need to input 14 to pass this 13 barrier since it's = 13 and not <= 13

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Dante Matta-Echaurren ! I believe you're referring to the code in this question:

age = int(input("What is your age?  "))
if age < 13:
    print("Sorry you are not old enough to see this PG-13 movie")
else:
    print("Welcome to the movie")

We would have to put in 14 if that had been <=, but that's not what we want. The minimum age for PG-13 is 13. You must be at least 13 to watch the movie. That means that 13 year-olds are allowed to watch it. We don't want to exclude them here.

So if the age is less than 13, tell them they can't go in. Otherwise, let them in.

Hope this helps! :sparkles:

Oohhh ok i feel so stupid ! Thanks you very much for the comprehensive and throughout response.