The idea is to create a list of strings of a certain amount of characters preserving the order from the original list. The challenge is to accomplish it using only list comprehensions.
list_string = [ "aaa", "bb", "cc", "dd", "ee"]
str_len = 6
[some_list_comprehension]
The result should be something like ["aaabb", "ccddee"]
. The string aaabb
in the result list is 5 characters long, while the string ccddee
is 6, that is because strings in the original list cannot be chunked. The order of the strings is relevant while creating the result, but irrelevant in the result, so that the end list could be ["ccddee", "aaabb"]
but not ["eeddcc", "bbaaa"]
. Each string appears in the result list just the same number of times as in the original, meaning that all possible combinations of the strings is not really the objective in this problem, mostly because each string in the result list is created following the order in the original.
There are only 2 possible outputs:
["aaabb", "ccddee"]
or
["ccddee", "aaabb"]