I am trying to write a basic password checking program and whenever the user has used two attempts to entering the correct password I am supposed to print a hint as to how many letters are in their password. Password is the variable that I stored the correct string in.
elif attempts == 1:
letters = 0
for i in password:
if password[i].isaplha():
letters = letters + 1
print('There are',letters,'letters in your password')
My code gives the error
TypeErrorTraceback (most recent call last)
<ipython-input-195-c967c81bda5f> in <module>()
letters = 0
for i in password:
----> if password[i].isaplha():
letters = letters + 1
TypeError: string indices must be integers
What am I doing wrong?