Python Strings – Remove the last character of a string

In this post we will be removing the last character of a given string in Python, to do this we will be using an extension of string slicing. See the snippet of code below as an example, where the given string is ‘Hello Worlds’.

String="Hello Worlds"
print(String[:-1])


#Returns 'Hello World'

In the above we are slicing the string via the ‘:’ till the very last character which is represented via the ‘-1’.

Leave a Reply