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)
>Solution :
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)