Jun-11-2020, 02:56 PM
(Jun-11-2020, 02:33 PM)GOTO10 Wrote: I'm curious to hear from some of the more experienced coders on the forum what they think is the best way to do this. I understand that it's generally considered desirable to avoid usingrange(len(sequence))
, but I'm having a hard time doing so without adding lines of code or checks I wouldn't need otherwise.
Here is what I came up with:
l = ['a', 'b', 'c', 'd'] newl = [] for i in range(len(l) -1): newl.append(''.join(l[i] + l[i+1])) print(newl)
that worked perfectly for me. thank you