Created
October 19, 2015 07:25
-
-
Save accessnash/c16ff322d5d268455dac to your computer and use it in GitHub Desktop.
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
"""Create a list of words from a line of input""" | |
words = set() | |
words_dict = {} | |
while True: | |
text = input("Enter a sentence: ") | |
if not text: | |
print("Finished") | |
break | |
textwords = text.lower().split() | |
for word in textwords: | |
if word not in words: | |
words.add(word) | |
count = len(words) | |
words_dict[word] = count | |
for k, v in words_dict.items(): | |
print (k, v) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment