Python Program to Find Prime Numbers in a Given Set of Number

# python program to find prime numbers in a given set of numbers
    
li = [1,4,5,7,8,9,11,13,24,28]   # a given list
prime = []   # empty list to store prime numbers 
for num in li:

    # all prime numbers are greater than 1 
    if num > 1:
        for i in range(2, num):
            if (num % i) == 0:
                break 
        else:
            prime.append(num) 
    print(prime)

Output:

[5, 7, 11, 13]


About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc






 PreviousNext