Python Program to find prime numbers in a list using the function


In this program, you will learn how to find prime numbers in a list using the function in Python.


list1 = [10, 11, 12, 13, 14, 15]

Example: How to find prime numbers in a list using the function in Python

def findPrime(list1):
    print("Prime numbers:")
    for num in list1:
        i = 2
        p = 1
        while i <= num / 2:
            if num % i == 0:
                p = 0
                break
            i = i + 1
        if p == 1:
            print(num)


list1 = [10, 11, 12, 13, 14, 15]
findPrime(list1)

Output:

Prime numbers:
11
13