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

else:

num is False

return num

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

if range_test(num):

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

else:

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

1 Answer

Relevance
  • EddieJ
    Lv 7
    6 months ago
    Best 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
      6 months agoReport

      https://answers.yahoo.com/question/index?qid=20190521232703AAT1I7w

Still have questions? Get answers by asking now.