I’m looking to format a simple integer i.e. 1 to print out 01:00 am. Reading the python string formatting made it even more confusing, right now what I have is "02" which will give me 01 but that’s about it 🙁
I’m looking to format a simple integer i.e. 1 to print out 01:00 am
Share
You can use string formatting to do this. You should use the
str.format()method, which is the preferred method – the old method (using the modulo (%) operator) is outdated and recommended against for new code: