[Solved] Beginner her. Could someone interpret this sentence. Thank you


ord() function will return the ascii value of a character.

The 2nd point says that you create a list of length 26 (as english letters are 26) and each entry will have the frequency of that letter.

Eg: ‘a’ = 0; ‘b’ = 1;… ‘z’: 25

ord('a') gives 97 – ASCII value of ‘a’.

Create a list of size 26 with all 0‘s

lst = [0] * 26

Now, the entry

lst[0] contains the frequency of character 'a'

lst[1] contains the frequency of character 'b'

lst[25] contains the frequency of character 'z'

Now the character a should map to lst[0]. To do that we do the following

ord('a') - ord('a') gives you 97-97 = 0. This is the index where a‘s frequency get stored – lst[0]

Similarly you offset the remaining characters by doing ord(character) - ord('a').

ord('b') - ord('a') = 98-97 = 1; lst[1]

ord('c') - ord('a') = 99-97 = 2; lst[2]

ord('z') - ord('a') = 122 – 97 = 25; lst[25]

solved Beginner her. Could someone interpret this sentence. Thank you