def reverse_lex(ustring):
 newstr = ''
 for ii in ustring:
  ordinance = ord(ii)
  new_byte = (255 - ordinance)
  char = chr(new_byte)
  newstr += char
 return newstr

def reverse_lex ( ustring ) : newstr = '' for ii in ustring : ordinance = ord ( ii ) new_byte = ( 255 - ordinance ) char = chr ( new_byte ) newstr += char return newstr
strings must be in unicode to reverse the string strings are returned in unicode and may not able able to be converted to a regular string args: ustring: string to reverse .