assigning a value to a character in string or text file in python

Solutions on MaxInterview for assigning a value to a character in string or text file in python by the best coders in the world

showing results for - "assigning a value to a character in string or text file in python"
Corbin
02 May 2019
1note:text can contain your text file that is already read or a string
2
3text = 'hello'
4
5vocab=sorted(set(text))
6char_to_ind = {char:ind for ind,char in enumerate(vocab)}
7
8