At the moment I have code that is looking through a huge string. It compares the string like this:
a = 0
for letter in my_str:
a += 1
if letter <= my_str[a]:
It keeps comparing all the way until the end when I get a ‘string index out of range’ error. I know it is because it is trying to compare the last character in the string to the next character (which doesn’t exist) How to fix this! I feel like I have tried everything. Help appreciated.
EDIT: Seems as though I have just figured out my solution… thanks anyways.
I just added another if statement at the beginning like the following..
Don’t know why it took me so long to figure that out!