Created
February 5, 2018 00:35
-
-
Save bha159/f4a94b85b96880608118dbdcb32de63d to your computer and use it in GitHub Desktop.
A python program to calculate occurence of a word in a text file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
word=input("Enter a word\n") | |
handle=open("my_data.txt") | |
data=handle.read().split(" ") | |
d=dict() | |
for i in data: | |
if i in d: | |
d[i]+=1 | |
else: | |
d[i]=1 | |
print("Occurence",d[word]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment