python_data_scien/poc2/poc2_mini_proj_2.py
def merge(list1, list2):
    """
    Merge two sorted lists.

    Returns a new sorted list containing those elements that are in
    either list1 or list2.

    This function can be iterative.
    """   
    result_list = []
    idx1 = 0
    idx2 = 0
    if len(list1) == 0 and len(list2) == 0:
        return []
    elif len(list1) != 0 and len(list2) == 0:
        return list1
    elif len(list1) == 0 and len(list2) != 0:
        return list2

    while True:
        if list1[idx1] == list2[idx2]:
            result_list.append(list1[idx1])
            result_list.append(list2[idx2])
            idx1 += 1
            idx2 += 1
        elif list1[idx1] < list2[idx2]:
            result_list.append(list1[idx1])
            idx1 += 1
        elif list1[idx1] > list2[idx2]:
            result_list.append(list2[idx2])
            idx2 += 1
        else:
            print 'error in func merge!!! p1'
            return

        if idx1 == len(list1) and idx2 < len(list2):
            result_list.extend(list2[idx2:])
            break
        elif idx1 < len(list1) and idx2 == len(list2):
            result_list.extend(list1[idx1:])
            break
        elif idx1 == len(list1) and idx2 == len(list2):
            break
        else:
            pass
    return result_list

    Merge two sorted lists.

    Returns a new sorted list containing those elements that are in
    either list1 or list2.

    This function can be iterative.
    
Merge two sorted lists.
Returns a new sorted list containing those elements that are in
either list1 or list2.

This function can be iterative.
Merge two sorted lists . Returns a new sorted list containing those elements that are in either list1 or list2 . This function can be iterative .
def merge(list1, list2):
    result_list = []
    idx1 = 0
    idx2 = 0
    if len(list1) == 0 and len(list2) == 0:
        return []
    elif len(list1) != 0 and len(list2) == 0:
        return list1
    elif len(list1) == 0 and len(list2) != 0:
        return list2
    while True:
        if list1[idx1] == list2[idx2]:
            result_list.append(list1[idx1])
            result_list.append(list2[idx2])
            idx1 += 1
            idx2 += 1
        elif list1[idx1] < list2[idx2]:
            result_list.append(list1[idx1])
            idx1 += 1
        elif list1[idx1] > list2[idx2]:
            result_list.append(list2[idx2])
            idx2 += 1
        else:
            print 'error in func merge!!! p1'
            return
        if idx1 == len(list1) and idx2 < len(list2):
            result_list.extend(list2[idx2:])
            break
        elif idx1 < len(list1) and idx2 == len(list2):
            result_list.extend(list1[idx1:])
            break
        elif idx1 == len(list1) and idx2 == len(list2):
            break
        else:
            pass
    return result_list
def merge ( list1 , list2 ) : result_list = [ ] idx1 = 0 idx2 = 0 if len ( list1 ) == 0 and len ( list2 ) == 0 : return [ ] elif len ( list1 ) != 0 and len ( list2 ) == 0 : return list1 elif len ( list1 ) == 0 and len ( list2 ) != 0 : return list2 while True : if list1 [ idx1 ] == list2 [ idx2 ] : result_list . append ( list1 [ idx1 ] ) result_list . append ( list2 [ idx2 ] ) idx1 += 1 idx2 += 1 elif list1 [ idx1 ] < list2 [ idx2 ] : result_list . append ( list1 [ idx1 ] ) idx1 += 1 elif list1 [ idx1 ] > list2 [ idx2 ] : result_list . append ( list2 [ idx2 ] ) idx2 += 1 else : print 'error in func merge!!! p1' return if idx1 == len ( list1 ) and idx2 < len ( list2 ) : result_list . extend ( list2 [ idx2 : ] ) break elif idx1 < len ( list1 ) and idx2 == len ( list2 ) : result_list . extend ( list1 [ idx1 : ] ) break elif idx1 == len ( list1 ) and idx2 == len ( list2 ) : break else : pass return result_list
Merge two sorted lists.
Merge two sorted lists .
"""
    Merge two sorted lists.

    Returns a new sorted list containing those elements that are in
    either list1 or list2.

    This function can be iterative.
    """
list1
list2