You can find the last character of a string in Python using negative indexing. Here's an example code snippet:
main.py71 chars4 lines
In the above code, my_string[-1]
returns the last character of the string "Hello, World!", which is "!". Negative indexing allows you to access elements from the end of the string, with -1
being the index for the last character.
gistlibby LogSnag