Reputation: 1
print("Enter the number you want to test")
Num1 = input("Enter your number here:")
if (Num1%1 == '0' and Num1%Num1 == '0'):
print ("This number is prime number")
else:
print("This number is nor prime number")
This is failing with an error of TypeError: not all arguments converted during string formatting
. What is the cause and how can I fix it?
Upvotes: 0
Views: 74
Reputation: 4528
input
returns a string
, you should convert it to int
:
Num1 = int(input("Enter your name here:"))
And if
parts changed to :
if (Num1%1 == 0 and Num1%Num1 == 0):
However your code logic for realize that a number is prime or not is not correct , you should check that number
has a factor or not , you should write a for
loop through it's lower numbers and realize that.it's simple but I think it's better for you that write it yourself.
Upvotes: 1