How to splice specific values of a list according to a set of parameters?

Hello, I’ve just started learning Python and can’t find a way to achieve this. I’d like to create a function that enables me to separate certain values from within any list of random numbers.

An example of this may be where I’d like to take out all numbers between 12 - 21 from the randomly generated list [ 5, 34, 73, 15, 20, 43, 19, 2, 88, 17, 39], the end result being an appended list with the values [15, 20, 19, 17].

There is likely a very simple solution to this however I just cannot figure it out nor find an answer anywhere, much appreciation to anyone reading.

[…]

I’d like to create a function that enables me to separate certain
values from within any list of random numbers.
[…]

There are many ways to go about this, but here are several basic
options:

[I tried to include links to more of Python’s documentation, but unfortunately this Web forum thinks I’m trying to send spam, so you’ll have to find it yourself.]

1 Like

Thank you for the sources! Apparently I had just been over complicating it the whole time… solved!