File tree Expand file tree Collapse file tree 1 file changed +3
-6
lines changed
Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Original file line number Diff line number Diff line change @@ -96,30 +96,27 @@ print(format_document_title("user guide", True) + " / "
9696
9797:::
9898
99- ## Iteration: Repeat an operation a specific number of times
99+ ## Iteration: Repeat an operation
100100
101101``` {python}
102102def count_words_in_documents(documents: list) -> dict:
103103 """Count total words across multiple documents."""
104104 word_counts = {}
105105 for doc_name in documents:
106- # simulate getting word count for each document
107106 word_count = len(doc_name.split()) # simple word count
108107 word_counts[doc_name] = word_count
109108 return word_counts
110109
111110# test with sample document names
112- docs = ["User Manual", "Installation Guide", "API Reference"]
111+ docs = ["Manual", "Installation Guide", "API Reference Document "]
113112counts = count_words_in_documents(docs)
114113print(counts)
115114```
116115
117- ::: {.incremental .fade style="margin-top: 0.5em ; font-size: 0.925em ;"}
116+ ::: {.incremental .fade style="margin-top: -0.25em ; font-size: 0.8em ;"}
118117
119118- ` word_counts ` is a dictionary that starts out empty
120- - ` documents ` is a list of document names
121119- The ` for ` loop iterates through each document name in the list
122- - The body of the loop counts words and stores result in dictionary
123120- ** Document connection** : analyzing multiple documents in a collection!
124121
125122:::
You can’t perform that action at this time.
0 commit comments