I want to be able to interleave two lists that could potentially be unequal in length. What I have is:
def interleave(xs,ys):
a=xs
b=ys
c=a+b
c[::2]=a
c[1::2]=b
return c
This works great with lists that either equal in length or just +/-1. But if let's say xs=[1,2,3] and ys= ["hi,"bye","no","yes","why"] this message appears:
c[::2]=a
ValueError: attempt to assign sequence of size 3 to extended slice of size 4
How do I fix this with using indexing? or do I have to use for loops? EDIT: what I want is to have the extra values just appear at the end.