Last modified: Jan 10, 2023 By Alexander Williams
2 methods to Remove last Character from String python
Remove the last character from the string Using [:-1]
my_string = "Hello Python" # 👉️ String
rm = my_string[:-1] # 👉️ Remove Last character
print(rm) # 👉 Print
Output:
Hello Pytho
Remove the last character from the string Using rstrip()
my_string = "Hello Python" # 👉️ String
rm = my_string.rstrip(my_string[-1]) # 👉️ Remove Last character
print(rm) # 👉 Print
Output:
Hello Pytho