Write a function AMCount(),which should read each character of "story.txt",should count and display the occurance of alphabets A and M(including small cases a and m too
Answers
Answered by
7
Answer:
def AMcount():
file = open("story 1.txt", 'r')
read = file.read()
countA = 0
countM = 0
for letter in read:
if letter in ["a", "A"]:
countA = countA+1
elif letter in ["m", "M"]:
countM = countM+1
print("A or a:", countA)
print("M or m :", countM)
AMcount()
Explanation:
Answered by
0
Answer:
def AMCount( ):
f = open("STORY.txt", "r",)
data = f.read()
count_a = 0
count_m = 0
for i in data :
if i == "a" or i == "A":
count_a += 1
elif i == "m" or i == "M":
count_m += 1
print("A or a :", count_a )
print("M or m:", count_m)
AMCount()
Similar questions
History,
2 months ago
English,
2 months ago
Science,
2 months ago
Hindi,
5 months ago
Computer Science,
5 months ago
India Languages,
10 months ago
Math,
10 months ago
Chemistry,
10 months ago