old python code to latest version ?

i found an old snippet but not working in latest python
problem wtih concatenation?

p1= [2] + range(3,N,2)

is there some way to convert this range to add it to the list
using latest python and work hopefully
this is supposed to be a fast algo hope it can still be fast after conversion!


doesn’t make much sense but here it is:

p1 = [2] + list(range(3, N, 2))

i would rather use:

p1 = [2]
p1.extend(range(3, N, 2))

or if you wanted this to be a custom generator function:

def p1_gen(N):
    yield 2
    yield from range(3, N, 2)