0

Been stuck on generator text split

Given a string as input, create a generator function that splits the string into separate words and outputs the resulting list. Sample Input This is some text Sample Output ['This', 'is', 'some', 'text']

1st Jul 2022, 10:26 PM
Tamekka
Tamekka - avatar
6 Antworten
+ 5
Tamekka You should show where you got stuck, by adding in your question description: 1. A link to your code in Code Playground 2. An explanation of your difficulties This is how we know what to help you on. That said, I recommend redoing the lesson on generators.
1st Jul 2022, 10:45 PM
Emerson Prado
Emerson Prado - avatar
+ 5
SoloProg , the request is to create a generator function, that splits .... your code is a NOT a generator, it does just uses print() with input() and split() inside. a generator function is using the yield statement here is a simple generator function, that capitalizes the first letter of each word: def string_caps(string): lst = string.split() for item in lst: yield item.capitalize() text = " hello out there" for word in string_caps(text): print(word)
2nd Jul 2022, 12:56 PM
Lothar
Lothar - avatar
+ 3
SoloProg Why do you insist in giving finished code as answer, after so many warnings? Do you really want to avoid people to follow steps, finding solutions, then learning?
1st Jul 2022, 10:48 PM
Emerson Prado
Emerson Prado - avatar
0
Can you please help . for some reason this one gets me
1st Jul 2022, 10:27 PM
Tamekka
Tamekka - avatar
0
Lothar Pls see my answer to SoloProg . It is suitable to everyone.
2nd Jul 2022, 2:57 PM
Emerson Prado
Emerson Prado - avatar
- 1
x = input() print(x.split())
2nd Jul 2022, 3:51 PM
Oleh Davydenko
Oleh Davydenko - avatar