Implement Python logic to determine the “last’ letter of the
alphabet in following string.
my_str = "I went fishing, crabbing,
and swimming yesterday. It was a great day, and I hope to do it
again next weekend."
The ‘last’ character of the provided string (my_str) is
‘y’
Feel free to convert the string to all upper or lower case letters
first.
my_str = "I went fishing, crabbing, and swimming yesterday. It was a great day, and I hope to do it again next weekend." my_str = my_str.lower() letter = my_str[-1] n = 2 while not letter.isalpha(): letter = my_str[-n] n = n + 1 print("The 'last' character of the provided string (my_str) is '"+letter+"'")
Get Answers For Free
Most questions answered within 1 hours.