Following function is required: A textfile, which needs to be read into Python, and the words have to be sorted by alphabetic order as an output into a dictionary.
A given textfile:
Im about to go to the movies on Monday!
And Im very excited to go.
Following code reads the file and removes unecessary characters:
def movietext():
with open("movietext.txt", "r") as textfile:
text = textfile.read()
for char in "!":
text=text.replace(char,"")
return text
print(movietext())
Which results in the following:
Im about to go to the movies on Monday
And Im very excited to go
The requirement from this is to get a dictionary printed out as following:
And: 1
about: 1
excited: 1
go: 1
Im: 2
Monday: 1
movies: 1
on: 1
the: 1
to: 3
very: 1
Very thankful for any kind of help on solving this.