Skip to content

Instantly share code, notes, and snippets.

View Prodge's full-sized avatar

Prodge Prodge

View GitHub Profile
@Prodge
Prodge / merge.py
Last active August 12, 2016 03:06
Python: Merge two lists recursivley alternating between the heads of each list
def merge_lists_into_string(a, b, string):
'''
Takes two lists of varying size and merges them like so:
([1,2,3], [10, 20, 30, 40, 50]) >> [1, 10, 2, 20, 3, 30, 40, 50]
'''
if a:
string += a.pop(0)
if b:
string += b.pop(0)
if a or b: