def g( x ) : ''' Solves the uate.g() homework 24 problem description ''' # General Accumulation Function For a List # accumulator = [] # for ... # accumulator.append( ... ) # return accumulator answer = [] # We want to build up a list of unique strings (accumulator) for element in x: # Look at each element in x one by one # We don't want to add elements that are already in our answer list! if ( element not in answer ): # If it's not already in our list of unique strings answer.append( element ) # Add the element to our answer! return answer ''' DO NOT MODIFY THE BELOW CODE '''' if ( __name__ == '__main__' ) : import uate x1 = [ 0, 1, 2 ] x2 = [ 0, 4, 1, 2, 2, 1, 3, 6, 3, 3, 4 ] x3 = [ ] z1 = uate.g( x1 ); print( 'g( x1 ) =', z1 ) z2 = uate.g( x2 ); print( 'g( x2 ) =', z2 ) z3 = uate.g( x3 ); print( 'g( x3 ) =', z3 )