Program 1 Read a text file and display the number of vowels
Program 1 Read a text file and display the number of vowels
Output:
def count_words(text):
"""Count the frequency of each word in the text."""
words = text.split()
word_count = {}
for word in words:
if word in word_count:
word_count[word] += 1
else:
word_count[word] = 1
return word_count
def main():
filename = 'phishing_emails.txt' # Change this to the path of your
text file
text = read_file(filename)
word_count = count_words(text)
most_common_words = get_most_common_words(word_count)
if __name__ == "__main__":
main()Program 15 Read a text file line by line and display each word
separated by a #
Output: