LearnPy Hub
← Comprehensions problems
Hard

Primes Comprehension

Read n and print a list of the primes up to n using a single list comprehension with all().

Input

One integer n ≥ 2.

Output

A list.

Sample 1

Input
30
Output
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]

Sample 2

Input
2
Output
[2]
solution.py
Output appears here
Primes Comprehension · Python practice problem · LearnPy Hub