how to get prime numbers in a list in python using list comprehension

Solutions on MaxInterview for how to get prime numbers in a list in python using list comprehension by the best coders in the world

showing results for - "how to get prime numbers in a list in python using list comprehension"
Sofia
01 Feb 2020
1>>> [x for x in range(2, 20)
2     if all(x % y != 0 for y in range(2, x))]
3[2, 3, 5, 7, 11, 13, 17, 19]
4