How to format numbers to strings in Python?
Answers
HOLA BUDDY....
Python 2.6+
It is possible to use the format() function, so in your case you can use:
return '{:02d}:{:02d}:{:.2f} {}'.format(hours, minutes, seconds, ampm)
There are multiple ways of using this function, so for further information you can check the documentation.
Python 3.6+
f-strings is a new feature that has been added to the language in Python 3.6. This facilitates formatting strings notoriously:
return f'{hours:02d}:{minutes:02d}:{seconds:.
#hope it helps you....
Plzz mark it as brainliest... ^·^
Python 2.6+
It is possible to use the format() function, so in your case you can use:
return '{:02d}:{:02d}:{:.2f} {}'.format(hours, minutes, seconds, ampm)
There are multiple ways of using this function, so for further information you can check the documentation.