def chars_to_dictionary(string):
 chars = set(string)
 char_idx = {c: i for (i, c) in enumerate(sorted(chars))}
 return char_idx

def chars_to_dictionary ( string ) : chars = set ( string ) char_idx = { c : i for ( i , c ) in enumerate ( sorted ( chars ) ) } return char_idx
creates a dictionary char:integer for each unique character .