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

21st Apr 2018, 6:30 AM
Jeff Myers
Jeff Myers - avatar
2 odpowiedzi
+ 7
As input product is a string, you can slice it: x = 'solo' print(x[:-1]) >>> sol
21st Apr 2018, 6:54 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 5
Slicing, I think you want it like this? s = "abcd" s = s[0:-1] print(s) The second line removes the last letter.
21st Apr 2018, 6:53 AM
Paul
Paul - avatar