remove everything after last occurence of a character python code example Example: python remove last 4 characters from string foo = foo[:-n]