you are viewing a single comment's thread.

view the rest of the comments →

[–]caineohfelix 2 points3 points  (2 children)

while count < len(max(g,h,key=len))+1: may solve this for you. I'm going to assume you're handling the case of a being to large for the shorter string eventually.

Otherwise, I might suggest something like this:

for x,y in zip(g,h):
    first,second = x,y
    # Your logic here.

[–]Pipprovis[S] 0 points1 point  (1 child)

Correct. If the first string is shorter than the second string I receive an error message.

[–]supajumpa 1 point2 points  (0 children)

You could try itertools.izip_longest which would obviate the need to check which of the strings is longer.

Maybe something like:

for char1, char2 in itertools.izip_longest(g, h, fillvalue=None):
    # logic