For example if I have a string like this:
a = "[email protected]:/home/hello/there"
How do I remove the last word after the last /
. The result should be like this:
[email protected]:/home/hello/
OR
[email protected]:/home/hello
Try this:
In [6]: a = "[email protected]:/home/hello/there"
In [7]: a.rpartition('/')[0]
Out[7]: '[email protected]:/home/hello'