-1

How to filter only the prime numbers in a given list using lambda function and list comprehension using python ?

LIST = [1,3,21,17,44,65]

5/21/2019 3:17:10 AM

e krizal

2 Answers

New Answer

+2

Once the lambda function isPrime() has been defined do the following. lst = [1, 3, 21, 17, 44, 65] new_lst = [i for i in lst if isPrime(i)] print(new_lst) # [3, 17]

+1

Thanks Diego