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: The Solution8:06

Can someone please explain this snippit of code to me?

 if not user > 0 or not user < 11:
        print( "That num isn't between 1 and 10." )
        break

I understand the rest of the code!

2 Answers

Hi Yehuda,

This is a conditional that is used to check and make sure that player_num is a valid number between 1 and 10.

The code in the conditional outputs a message and breaks out of the loop if player_num is either not greater than 0 or if it is not less than 11.

  if not player_num > 0 or not player_num < 11:
    print("That number isn't between 1 and 10!")
    break

Thanks Hanley Chan,

Helped alot!

Hi Yehuda,

It's saying that if the number (or in the code that you provided, user) is not greater than 0, or user is not less than zero then break. It is the same as saying if user is less than 0 or greater than 11, break because the number is not in the 1-10 range.

Let me know if you have any questions.

Thanks Iman Mk,

That explains it, now I understand it!