0
我使用Python版本3.5和输入此代码为素数:::不受支持的opperand类型错误。我使用<code>input()</code>它在使用Python版本3
num=input("enter number to be checked : ")
ctr=0
i=1
for i in range(1,(num/2)+1):
if(num%i==0):
ctr+=1
if(ctr==0):
print(num," is prime")
else:
print(num," is not prime")
和收到此错误::::
enter number to be checked : 5
Traceback (most recent call last)
file "prime.py", line 4 in (module)
for i in range(1,(num/2)+1):
type error: unsupported opperand type(s) for/:str and int
将您的输入作为'int'读入,如'num = int(input(“enter number of checked:”))''。 – shivsn