Method # 1: Using List Comprehension + Tuple
This is one approach in which this task can be accomplished. In this we just iterate over the String, break up the chunks of the string, and create a tuple using tuple () in one liner.
The original string: ggggffffgggg Chunked String into tuple: (`gggg`,` ffff`, `gggg`)
Method # 2: Using
zip () + iter () + join () + list comprehension
A combination of the above functions can also be used to accomplish this task. In this, we are going through the chunk creation process using zip () + iter (). And accumulate the result using join ().