[Solved] Python – Get user to input 10 numbers and then display only the prime numbers [closed]


At very simple i make this program for you as per your requirement that user must enter 10 numbers and program finds either it is prime or not.

try this:

for i in range(0, 10):
    num = int(input('Enter Number:'))
    if num > 1:
        # check for factors
        for i in range(2, num):
            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")

    # if input number is less than
    # or equal to 1, it is not prime
    else:
        print(num, "is not a prime number")

Note: In a for loop a take input from user 10 times if you want to take inputs in the starting then you can also to that and you can then run a loop o that list. Choice is yours!

solved Python – Get user to input 10 numbers and then display only the prime numbers [closed]