Search Results

Search found 1 results on 1 pages for 'user2829177'.

Page 1/1 | 1 

  • how to interleaving lists

    - by user2829177
    I have two lists that could be not equal in lengths and I want to be able to interleave them. I want to be able to append the extra values in the longer list at the end of my interleaved list.I have this: a=xs b=ys minlength=[len(a),len(b)] extralist= list() interleave= list() for i in range((minval(minlength))): pair=a[i],b[i] interleave.append(pair) flat=flatten(interleave) c=a+b if len(b)>len(a): remainder=len(c)-len(a) for j in range(-remainder): extra=remainder[j] extralist.append(extra) if len(a)>len(b): remainder=len(c)-len(b) for j in range(-remainder): extra=remainder[j] final=flat+extralist return final but if I test it: >>> interleave([1,2,3], ["hi", "bye",True, False, 33]) [1, 'hi', 2, 'bye', 3, True] >>> The False and 33 don't appear. What is it that Im doing wrong?

    Read the article

1