file=open("apple.txt","r")
letters=0
for line in file:
words=line.split()
for character in words:
character = int(character)
if character<=90 and character>=65: #ascii code for the uppercase letters
letters+=1
elif character<=122 and character>=97: #ascii code for lowercase letters
letters+=1
print(letters)
The error i get is if int(character)<=90 and int(character)>=65:ValueError: invalid literal for int() with base 10: 'I' Im not too sure what. Also my txt file contains I ate apples. 123 I am trying to make it so it will only count the letters I ate apples so I should see only see 10 letters when the program goes through. If someone can help with this it would be much appreciated.