Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
Bonsai Boy of New York Bonsai Trees and Accessories

BlueHost Web Hosting

Liquid Web iThemes WordPress Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

DreamHost Web Hosting


getResponse autofunnels

Liquid Web Cloud VPS Hosting

11,619 questions

15,845 answers

573 users

How to find of all the prime numbers in a list with Python

1 Answer

0 votes
import math
 
def is_prime(num):
    if num == 0:
        return 0
    if num == 1:
        return 0
    for p in range(2, int(round(math.sqrt(num))) + 1):
        if int(round(num % p)) == 0:
            return 0
    return 1


lst = [4, 8, 17, 5, 9, 22, 21, 13, 18, 99]

for i in range(len(lst)): 
    if is_prime(lst[i]):
        print(lst[i])



'''
run:

17
5
13

'''

 




answered Oct 19 by avibootz
...