+ 1

Text analysis doubt

The code given below is to find percentage oof characters that each character occupies in a text file. Please explain me last print statement for char in "abcdefghijklmnopqrstuvwxyz": perc = 100 * count_char(text, char) / len(text) print("{0} - {1}%".format(char, round(perc, 2)))

17th Dec 2020, 12:58 PM
Harshita Sharma
Harshita Sharma - avatar
4 Réponses
+ 1
f string and format string. Check at python course
17th Dec 2020, 1:21 PM
Shadoff
Shadoff - avatar
+ 1
copy paste below code and see. Hope you will understand: a = "Aman" b = "Bayram" print(f'{a} and {b} are friends') print("{0} and {1} are friends".format(a,b))
17th Dec 2020, 3:02 PM
Shadoff
Shadoff - avatar
0
What is this ({0}-{1}%) for?
17th Dec 2020, 2:49 PM
Harshita Sharma
Harshita Sharma - avatar
0
Ohk..i got it. Thanks
17th Dec 2020, 3:04 PM
Harshita Sharma
Harshita Sharma - avatar