Unexpected print output for python string formatting

I want to print some values using str.format. However, I am getting the first value repeated, which I do not understand. any help will be appreciated.

for tel in ['T1', 'T2', 'T3', 'T4']:
    print(tel+':{0:.2f}, {0:.2f}, {0:.2f}'.format(0.56, 0.12, 0.25))

Read more here: https://stackoverflow.com/questions/64899167/unexpected-print-output-for-python-string-formatting

Content Attribution

This content was originally published by vinod kumar at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: