Skip to content

Instantly share code, notes, and snippets.

@accessnash
Created October 19, 2015 07:25
Show Gist options
  • Save accessnash/c16ff322d5d268455dac to your computer and use it in GitHub Desktop.
Save accessnash/c16ff322d5d268455dac to your computer and use it in GitHub Desktop.
"""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