num = int(input("Enter a number: "))
if num==0 or num<0:

    continue
else:
    if num > 1:

       if (num % i) == 0:
           print(num,"is not a prime number")
           print(i,"times",num//i,"is",num)
           break
   else:
       print(num,"is a prime number")
Re: Python program for prime numbers. can you help me out with continue loop? 80 80

Where is the loop?

Re: Python program for prime numbers. can you help me out with continue loop? 80 80

Generally:

# show prime numbers
# prime numbers are only divisible by unity and themselves
# (1 is not considered a prime number)

for n in range(2, 100):
    for x in range(2, n):
        if n % x == 0:
            # found a factor
            #print(n, 'equals', x, '*', n/x)  # optional
            break
    else:
        # note this else has to line up with second for, not the if
        # means loop fell through without finding a factor
        print(n, 'is a prime number')
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.