Reputation: 439
So I want to change the last character in a string to lower case. The code below is the method I am using to print a string backwards, but list leaves the last character as a capital and I can't figure out how to fix this!
if s[-1] == "x":
new = ""
last_index = len(s)-1
for i in range(last_index, -1, -1):
new += s[i]
s = new
s = "".join(word[0].upper() + word[1:] for word in s.split())
print (s)
e.g: The input is:
Inbox
and this outputs:
XobnI
But I want it to output:
Xobni
Thanks in advance!
Upvotes: 1
Views: 1388