Python range function?

I made a range function for a Python problem, but for some reason it's always retuning as true for the numbers even when it is false. Where might the error in the code be?

def range_test(num):

if num > 1 and num < 555:

num is True


num is False

return num

num = int(input("Enter a number: "))

if range_test(num):

print( "{:d} is in range.".format(num))


print("The number you entered is outside the range!")

1 Answer

  • EddieJ
    Lv 7
    8 months ago
    Favorite Answer

    num is True

    is a test. It is NOT an assignment.

    You could use

    def range_test (num):

    ... return num> 1 and num < 555

    • EddieJ
      Lv 7
      8 months agoReport

    • Login to reply the answers
Still have questions? Get your answers by asking now.