I have a list like
[(1, 3), (6, 7)]
and a string
'AABBCCDD'
I need to get the result AABCD.
I know I can get the integers form the tuple with nameOfTuple[0][0] yielding 1.
I also know that I can get the chars form the string with nameOfString[0] yielding A.
My question is, how do I iterate through two arguments in the tuple, in order to save the integers (to a list maybe) and then get the chars from the string?
I have a list like [(1, 3), (6, 7)] and a string ‘AABBCCDD’ I
Share
Here, pairs of indices from
lare assigned tostartandend, one pair at a time. The relevant portion of the string is then extracted usings[start-1:end], yielding a sequence of strings. The strings are then merged usingjoin().