0

Using generators on string lists

Ok I keep running into confusion over how to manipulate string lists. Integers are easy, for example just using the max() function will print the max. However I get confused on how to translate a list of words or strings into an integer based function. For example right now I am stuck on the generator challenge problem, which involves manipulating a string. Does anyone have any good tips or hints on how best to handle the manipulation of string lists using functions and generators?

28th Nov 2020, 10:56 PM
Karsa9Fingers
Karsa9Fingers - avatar
4 odpowiedzi
+ 1
I think you'll be to be a little more specific. What are you trying to do to the string? max() works on string (or list of words) too.
28th Nov 2020, 11:02 PM
rodwynnejones
rodwynnejones - avatar
+ 1
All you need there is the str.split function: print(input().split())
28th Nov 2020, 11:28 PM
Benjamin Jürgens
Benjamin Jürgens - avatar
0
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']
28th Nov 2020, 11:06 PM
Karsa9Fingers
Karsa9Fingers - avatar
0
That works but the challenge is to use a generator in python, and use the “yield” function
29th Nov 2020, 1:08 AM
Karsa9Fingers
Karsa9Fingers - avatar