+ 1
Can soneone please explain this code to me?
I can't understand this code portion for char in "abcdefghijklmnopqrstuvwxyz": perc = 100 * count_char(text, char) / len(text) print("{0} - {1}%".format(char, round(perc, 2)))
1 Resposta
+ 6
Without seeing text, it is a guess. But, likely.
For each character in the alphabet (for statement), count how many times it is found in the text (count_char method call.) Generate the percentage of that character in the entire string (rest of the equation assigning to perc.) Print the character and it's percentage (print method call.)