text = "to be or not to be"
words = text.split()
word_counts = {}
for word in words:
if word in word_counts:
word_counts[word] += 1
else:
word_counts[word] = 1
print(word_counts)
To embed this project on your website, copy the following code and paste it into your website's HTML: