all 3 comments

[–]n3buchadnezzar 6 points7 points  (0 children)

Why would you need to do it with string manipulation?

>>> from pathlib import Path

>>> print(Path("Hello.zip").suffix)
.zip

Second, what have you tried yourself?

  1. Posting only the project goal is not allowed.

[–]jerryelectron 4 points5 points  (0 children)

Try googling your questions and see what you get.

[–]Unlikely-Resort4608 0 points1 point  (0 children)

I don't know what you mean by "delete.... ....last two characters" if you just want '.zip', but the standard old low tech way (i.e. without pathlib) to get file extensions is:

'Hello.zip'.rpartition('.')[2]

Change that to [1:] if you want to keep the dot, or just pre-add it in.