Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 938f4e3

Browse filesBrowse files
dvdvgtabranhe
authored andcommitted
word:length dict
1 parent 12007f0 commit 938f4e3
Copy full SHA for 938f4e3

File tree

Expand file treeCollapse file tree

1 file changed

+10
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-0
lines changed

‎strings/word_length_dict.py

Copy file name to clipboard
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""
2+
Determines the length of each word in a string and puts the word and its length in a dictionary
3+
"""
4+
5+
def word_length_dict(text):
6+
d = {e: len(e) for e in text.split(" ")}
7+
return d
8+
9+
text = "The quick brown fox jumps over the lazy dog"
10+
print(word_length_dict(text))

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.