python - Why is this comparison failing? -
print("enter number want test") num1 = input("enter number here:") if (num1%1 == '0' , num1%num1 == '0'): print ("this number prime number") else: print("this number nor prime number") this failing error of typeerror: not arguments converted during string formatting. cause , how can fix it?
input returns string , should convert int:
num1 = int(input("enter name here:")) and if parts changed :
if (num1%1 == 0 , num1%num1 == 0): however code logic realize number prime or not not correct , should check number has factor or not , should write for loop through it's lower numbers , realize that.it's simple think it's better write yourself.
Comments
Post a Comment