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?
4 Answers
+ 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.
+ 1
All you need there is the str.split function:
print(input().split())
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']
0
That works but the challenge is to use a generator in python, and use the âyieldâ function