Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def find_most_frequent(text):
- import math
- dict_for_words_and_numbers_of_words = {}
- list_for_dict_values = []
- list_for_dict_keys = []
- text = text.lower()
- for i in text:
- if not str(i).isalpha() and i != ' ':
- text = text.replace(i, '')
- text = text.split()
- for word in text:
- if word in dict_for_words_and_numbers_of_words:
- dict_for_words_and_numbers_of_words[word] += 1
- else:
- dict_for_words_and_numbers_of_words[word] = 1
- for i in dict_for_words_and_numbers_of_words.values():
- list_for_dict_values.append(i)
- for i in dict_for_words_and_numbers_of_words.keys():
- list_for_dict_keys.append(i)
- kk = []
- for i in range((len(list_for_dict_values))):
- if list_for_dict_values[i] == max(list_for_dict_values):
- kk.append(list_for_dict_keys[i])
- return print(kk)
- find_most_frequent('my name is andrew Is my best name')
Add Comment
Please, Sign In to add comment