def rs_swap(a, b):
 d = {}
 for rsa in a:
  d[rsa] = [rsb for rsb in b if (rsa.symbol == rsb.symbol)][0]
 return d

def rs_swap ( a , b ) : d = { } for rsa in a : d [ rsa ] = [ rsb for rsb in b if ( rsa . symbol == rsb . symbol ) ] [ 0 ] return d
build a dictionary to swap randomsymbols based on their underlying symbol .