- 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]

21st May 2019, 3:17 AM
Krishna
Krishna - avatar
2 Respuestas
0
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]
21st May 2019, 4:38 AM
Diego
Diego - avatar
0
Thanks Diego
21st May 2019, 5:57 AM
Krishna
Krishna - avatar