Getting IndexError: string index out of range in python, I'm a beginner in python and trying to make a program that will count total uppercase and lowercase letters and I have also tried some solutions as removing spaces of a string as string.replace(" ", "") but again getting error,
My code
string = input('Enter string upto 25 words: ')
if len(string) > 25:
print('Please enter a string less than 25 words.')
else:
string.replace(" ", "")
total_upr = 0
total_lwr = 0
i = 0
while i < 25:
print(i)
if string[i].islower():
total_upr += 1
elif string[i].isupper():
total_lwr += 1
i += 1
print(f"'{string}' contains {total_lwr} lower-case letters and {total_upr} upper-case letters.")