How do I format this? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How do I format this?

How do I format my output using f string if I want to display hh:mm:ss with two digits regardless whether the value is a one digit number, likesay 8:8:8 should be 08:08:08?

15th Sep 2021, 12:00 AM
Ivan Bessarab
Ivan Bessarab - avatar
2 Answers
+ 4
hour = 8 min = 8 sec = 8 print(f"{hour:02}:{min:02}:{sec:02}")
15th Sep 2021, 12:45 AM
ChaoticDawg
ChaoticDawg - avatar
0
I cant understand your question
15th Sep 2021, 12:14 AM
Richard
Richard - avatar