Jan-13-2017, 04:04 PM
>>>I have to do it in just one line
>>If i just use feedback.split()
it returns words as individual elements of a list
BUT,
what I want is that the length of each element of the list should be of the parameter (s).
How do I configure length of each split?
>>The other thing is,
if two words have a joint length less than (size) , they should be stored as a single element,which the .split() function does not do.
>>If i just use a list compression,
I will have to write a long piece of code that will check for white spaces and then recognize the character behind the whitespaces as single words, check their length, add the next word if it can satisfy the (size) criteria.
[feedback[i:i+size] for i in range(0, len(feedback), size)]
it will just read individual characters and not words and then store them by size in a list .
>>If i just use feedback.split()
it returns words as individual elements of a list
BUT,
what I want is that the length of each element of the list should be of the parameter (s).
How do I configure length of each split?
>>The other thing is,
if two words have a joint length less than (size) , they should be stored as a single element,which the .split() function does not do.
>>If i just use a list compression,
I will have to write a long piece of code that will check for white spaces and then recognize the character behind the whitespaces as single words, check their length, add the next word if it can satisfy the (size) criteria.
[feedback[i:i+size] for i in range(0, len(feedback), size)]
it will just read individual characters and not words and then store them by size in a list .