format function accepts only strings?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

format function accepts only strings??

for j in string.ascii_lowercase: print(" {0} = {1}% ",format(j, round((100*count_char(j)/t), 2))) Traceback (most recent call last): File "<pyshell#110>", line 2, in <module> print(" {0} = {1}% ",format(j, round((100*count_char(j)/t), 2))) TypeError: format() argument 2 must be str, not float

12th Dec 2018, 1:11 PM
Hari K
1 Answer
+ 6
Hi Hari I think the comma (,) before format() should be a period (.). If that doesn't fix the issue, do you mind saving the full code in Code Playground and sharing the link? Thanks!
12th Dec 2018, 1:30 PM
Kishalaya Saha
Kishalaya Saha - avatar