-1

Please help in writing a program that will count the letters 'a' in a sentence. I need to use a 'for' loop.

text = input("Give a sentence and I will count the number of letters 'a'\n") 
for letter in text:
    a_text = text.count('a')
    print(a_text)

1 Answers1

0
text = input("Give a sentence and I will count the number of letters 'a'\n")

count = 0
for letter in text:
    if letter == 'a':
        count += 1

print("The number of 'a' is:", count)
Dharman
  • 30,962
  • 25
  • 85
  • 135