When I run the following code on a string words
:
def word_feats(words):
return dict([(word, True) for word in words])
print(word_feats("I love this sandwich."))
I get the output dict-comprehension in letters instead of words:
{'a': True, ' ': True, 'c': True, 'e': True, 'd': True, 'I': True, 'h': True, 'l': True, 'o': True, 'n': True, 'i': True, 's': True, 't': True, 'w': True, 'v': True, '.': True}
What am I doing wrong?
You have to
split
thewords
string:Example
You can also use other characters on which to split:
Your Code