Is it possible for me to do the following, and if so, what am I doing wrong?
I want to grab the last item in a list, and rely on .find() to return the last item, even if the list is empty.
I have a list like this:
list = ["item1", "item2", "item3", "etc"]
and I want to get the last element even if it's empty. To do that, I access the last element using list[-1:]. My problem is that I believe I need to use the .find() on the last element of that list. However, if the list is empty, .find() does not work.
The reason that won't work is because list[-1] will return etc, but list[-1:] will return ['etc']. Any other ways to use .find() in this situation?