20240415 Word Count

Run Settings
LanguagePython
Language Version
Run Command
""" 10. ***Word Count***: Write a Python function that takes a string as input and returns the count of each word in the string""" def word_count(sentence): words = sentence.split() # split words into list word_count_dict = {} for word in words: if word in word_count_dict: word_count_dict[word] += 1 else: word_count_dict[word] = 1 return word_count_dict result = word_count("the quick brown fox jumps over the lazy dog") print(result)
Editor Settings
Theme
Key bindings
Full width
Lines