Sep-12-2019, 09:47 AM
(Sep-12-2019, 09:18 AM)luoheng Wrote: Replacewhile
withif
:
num = int(input("Enter a number here: ")) if num >= 2: for i in range(2, num): if num % i == 0: print(num," is not a prime number.") break else: print(num," is a prime number.")
Thanks luoheng,
I first had it similar to this, if statement prior to the for loop but I must have had something wrong as it did not work quite right. That's when I tried the while outer loop instead. Anyways,
Thanks for the pointer appreciate it.