Q:

how to remove last character from string in python

str =  "string"
str = str[:-1]  # Returns "strin"
16
st =  "abcdefghij"
st = st[:-1]  # Returns string with last character removed
14
#Removing last three characters
foo = foo[:-3]
2
test = ["80010","80030","80050"]
newtest = [x[:-1] for x in test]
1
your_string = "hello"
your_string = your_string[:-1] # this removes the last character from your string 
2
foo = foo[:-n]
0
str = "abc"
str = str[:-1]
print(str)

>>> ab
0
st =  "abcdefghij"
st = st[:-1]
-1
st="velm"
str = str[:-1] 
-1

New to Communities?

Join the community