Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with open(r'File directory', 'r') as file:
- f_input = file.readlines()
- def word_count(user_input):
- output = {}
- for word in user_input:
- if word not in output:
- output[word] = 1
- else:
- output[word] += 1
- return output
- output = {}
- for i in f_input:
- for key, value in word_count(user_input=[str(i).lower() for i in i.split()]).items():
- if key in output:
- output[key] += value
- else:
- output[key] = value
- for key, value in output.items():
- if value > 2: #Write repeat number that u want
- print(key, value)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement