whats the syntax for removing a specific number of characters from a string.
for example "name.pdf" I want to remove from the right the ".pdf"
Sorry this is a basic question. my searches aren't finding the answer.
or a little more cryptic
>>> txt = "name.pdf"
>>> a = txt[:-4] #strip off last 4 characters
the [ ] means that text is whats called an iterable, meaning each character can be cycled through
the [: means copy everything from the beginning (note the colon after the [ )
the -4] means everything except the last 4 characters (counting from the right)
hence it all means copy the "txt" variable (name.pdf) except the last 4 characters