- 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]
2 odpowiedzi
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]
0
Thanks Diego