Use the slice method to Python removes the last character from the string in python. Just use the negative index value “-1” to retrieve items from the end of the string.
Negative index starts from -1 to -(iterable_length).
Python remove the last character from the string Example
Simple example code. The index -1 gets you the last element from the iterable. The above program will print the string after removing the last char.
name = 'Python' res = name[:-1] print(res)
Do comment if you have any doubts and suggestions on this Python char string topic.
Note: IDE: PyCharm 2021.1.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.