how to remove last 5 characters from string in python code example Example: python remove last 4 characters from string foo = foo[:-n]