D
D
dana_882020-08-12 15:11:25
Python
dana_88, 2020-08-12 15:11:25

How can the result of defining one function be passed to a parameter when defining another function?

For example, there is a function definition def get_words(text: str) -> list, which results in a list of a list of tuples:
(
<word from text in lower case - str>,
<word start position - int>,
) you need to write a function def get_index_of_words(words: list) -> dict , which for each word forms a list of positions from which this word begins in the text. How to assign the result of the get_words(text) function to the words parameter? Please note that the function definition instruction `def get_index_of_words(words: list) -> dict:` is not allowed to be changed! An example of the result of the get_index_of_words(words) function:
5f33da1042eda306203831.png



5f33dc35be643031923369.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alan Gibizov, 2020-08-12
@dana_88

Firstly, you don’t need to sculpt screenshots here, it’s better to insert text and frame with tags.
Secondly,

text = “the text”
get_index_of_words(get_words(text))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question