You can (and should) ask ‘Python’ for help, but I’m guessing that nobody has told you about that.
As an example: you want to know how to “reverse” or “sort” a
list object (maybe you can “sort” in reverse order, right?).
If you use the REPL interface (AKA: the ‘Python shell’), you get a welcome message and
>>> prompt. As an example, if I open a terminal session and start the Python3 REPL, this is what I see:
Python 3.6.9 (default, Mar 10 2023, 16:46:00)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
Now I create a
list object and ask ‘Python’ for some help:
>>> my_list = [1,2,3,4]
Now I see quite a lot of ‘help’ and right there, near the end (use the arrow down key, or Pg Dn key) I see:
| L.reverse() -- reverse *IN PLACE*
| L.sort(key=None, reverse=False) -> None -- stable sort *IN PLACE*
Once you’re done reading, you simply press the ‘q’ key, to quit the help system.
So, we can now see that there are two ways that we can achieve the objective; both of which are
*IN PLACE*, which means that the list object will be remain that way, unless we perform an operation that alters it.
You should now be able to see that:
…will do what we need to do.
I hope this ‘mini guide’ is of some use to you.