There is a bug on line 23, I have no idea what goes wrong.
The code is a bit inefficient. You could have just done:
if string[i].upper() == string[i]:
# had to be uppercase
# had to be lowercase
It seems like your program is working just fine!
you are missing a bracket at the end of line 22 and 24 that will fix the problem