0
How do I delete a letter from user input?
I would like to make a palindrome. In order to do so I need to take the user input, subtract the last letter/number, reverse it, and put them together. I just can't figure out how to modify user input like that. https://code.sololearn.com/cgBTV8B2nlJB/?ref=app
2 Answers
+ 7
As input product is a string, you can slice it:
x = 'solo'
print(x[:-1])
>>>
sol
+ 5
Slicing, I think you want it like this?
s = "abcd"
s = s[0:-1]
print(s)
The second line removes the last letter.