# functional programming – Python – return list (or not?) of prime numbers between two numbers

If you are already into programming/STEM, you will already know finding prime numbers is a tough problem. Hence, I will not comment on the efficiency of checking whether a number is primer by checking all possible divisors (which is a terrible idea if you are trying to actually find prime numbers, but it is good enough if you are simply trying to learn).

Now, regarding what pythonic means, it does not refer to efficiency at all. It is about readability and the way the language features are used (it is explained in a bit more depth in this answer).

Furthermore, if you are new to python, and want to learn about best practises, I would recommend you giving a read to PEP-8. It is a style guide for python code widely followed by the community.

Edit:

Still, as a comment on your code, I feel the logic to check whether a number is primer or not is complex enough to be encapsulated in a function:

``````from typing import Iterable

def is_prime(num: int) -> bool:
return num>1 and all(num%i!=0 for i in range(2,num))

def get_primes(start: int, end:int) -> Iterable(int):
return (num for num in range(start,end+1) if is_prime(num))

get_primes(-41,41)
``````

If you are not yet familiar with it, the syntax used above is called type annotations. You can read more about it here.