So i'm trying to find a prime number. And my code works fine. But I'm just trying to get my code to print out with the %s format that my number is not prime.This is more of a conceptual question.
Error message below:
Traceback (most recent call last):
File "python", line 17, in
File "python", line 10, in is_prime
TypeError: 'str' object is not callable
I would've expected it to print: "Darn x is not a prime number" where x is the number I'm checking is prime. See code below.
def is_prime(x): n=2 if x <2: return False else: word = str(x) while n <= x-1: print n if x % n == 0: print "Darn %s is not a prime number"(word) return False break n += 1 else: print "Yay" return True print is_prime(4)