I'm writing a basic Python script, the code of which is as followsdef is_prime(n):
def is_prime(n):
i = 2
while i<n:
if(n%i == 0):
return False
i+=1
return True
def truncable(num):
li = []
x = str(num)
if(is_prime(num)):
n = len(x)
check = ""
i = 1
while(i<n):
if(is_prime(x[i:])):
check = "True"
else:
check = "False"
break
if(check == "True"):
li.append(num)
print truncable(3797)
However, after running this script, I get the following error:
TypeError: not all arguments converted during string formatting
What's wrong with my code?
TypeError: unorderable types: int() < str()which would have pointed out the underlying problem immediately.printwill result inNone, since you aren't returning anything fromtruncable.