0

Text

Can someone kindly decode this?? for char in "abcdefghijklmnopqrstuvwxyz": perc = 100 * count_char(text, char) / len(text) print("{0} - {1}%".format(char, round(perc, 2)))

22nd Feb 2020, 7:49 AM
Ojurongbe Yusuf
1 Resposta
+ 1
I don't think this is the whole code as count_char(), text are still not defined... But from what I see, It is used to check the percentage of characters used in the text... Something like in v= "aabbcdeefg" C - 10% as len(v) is 10 and count_char() should return 1 But I can't accurately say without looking at the while code about the loop- the loop will iterate through every character of "abcdefghijklmnopqrstuvwxyz" first char == 'a' perc will be the percentage of that character used in the text print("{0} - {1}%".format(char,round(perc,2))) It will print the element at 0th index i.e, the character and then 1st index, i.e, the percentage rounded to two figures in the format ()
22nd Feb 2020, 7:54 AM
Utkarsh Sharma
Utkarsh Sharma - avatar