I’m new to Python and coming from a PHP background.. I’m impressed. Is there a way of getting a list of numbers from this sequence:
i^2, i^2 + i, i^2 + 2i, ..., n
i.e. if i=2 and n=30:
4, 6, 8, ..., 30
Okay, this is a really simple sequence but is what’s a more general way to do this sort of thing functionally?
Maybe there’s some nice functional programming way of doing this? In PHP I think I would make some function some variables and interaction but Python might be able to do it more elegantly?
Many thanks.
You can do this with range: