#NEWLINE# def sorted_list_difference( expected , actual ) : #NEWLINE# #INDENT# 'Finds elements in only one or the other of two, sorted input lists.\n\n    Returns a two-element tuple of lists.    The first list contains those\n    elements in the "expected" list but not in the "actual" list, and the\n    second contains those elements in the "actual" list but not in the\n    "expected" list.    Duplicate elements in either input list are ignored.\n    ' #NEWLINE# i = j = 0 #NEWLINE# missing = [ ] #NEWLINE# unexpected = [ ] #NEWLINE# while True : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# e = expected [ i ] #NEWLINE# a = actual [ j ] #NEWLINE# if ( e < a ) : #NEWLINE# #INDENT# missing . append ( e ) #NEWLINE# i += 1 #NEWLINE# while ( expected [ i ] == e ) : #NEWLINE# #INDENT# i += 1 #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( e > a ) : #NEWLINE# #INDENT# unexpected . append ( a ) #NEWLINE# j += 1 #NEWLINE# while ( actual [ j ] == a ) : #NEWLINE# #INDENT# j += 1 #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# i += 1 #NEWLINE# try : #NEWLINE# #INDENT# while ( expected [ i ] == e ) : #NEWLINE# #INDENT# i += 1 #NEWLINE# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# j += 1 #NEWLINE# while ( actual [ j ] == a ) : #NEWLINE# #INDENT# j += 1 #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# except IndexError : #NEWLINE# #INDENT# missing . extend ( expected [ i : ] ) #NEWLINE# unexpected . extend ( actual [ j : ] ) #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# return ( missing , unexpected )