A text file “PARA.txt” contains a paragraph. Write a function that searches for a given character and reports the number of occurrence of the character in the file.
Answer:
def count_alpha():
c=0
x=input("Enter character to search for: ")
f=open("PARA.txt",'r')
l=f.readlines()
for
line in l:
for
word in line:
for
char in word:
if
char == x:
c=c+1
print("Number of occurrences of "+x+" = "+str(c))
f.close()