The program I am currently working on retrieves URLs from a website and puts them into a list. What I want to get is the last section of the URL.
So, if the first elemen
You can use rpartition():
>>> s = 'https://docs.python.org/3.4/tutorial/interpreter.html' >>> s.rpartition('/') ('https://docs.python.org/3.4/tutorial', '/', 'interpreter.html')
And take the last part of the 3 element tuple that is returned:
>>> s.rpartition('/')[2] 'interpreter.html'