0
'<' not supported between instances of 'int' and 'str'. 

What do i need to change?

this is a simple python command, but, I'm new, so I can't fix it myself.

from math import *
n = input("set range:- ")
p = [2, 3]
count = 2
a = 5
while (count < n):
    b=0
    for i in range(2,a):
        if ( i <= sqrt(a)):
            if (a % i == 0):
                print("a neprost",a)
                b = 1
            else:
                pass

    if (b != 1):
        print("a prost",a)
        p = p + [a]
    count = count + 1
    a = a + 2
print(p)

I don't even know what to expect, but i can't continue learning if i won't fix this.

TypeError: '<' not supported between instances of 'int' and 'str'
Siong Thye Goh
  • 3,518
  • 10
  • 23
  • 31
daniel
  • 61
  • 1
  • 7

1 Answers1

2

Notice the line

count < n

count hear is an int (with value 2) but n which comes from the input argument is a string. Hence that is why you get the error. To fix the problem, convert n to an int by using the int function.

n = int(input("set range:- "))
Siong Thye Goh
  • 3,518
  • 10
  • 23
  • 31