I want to be able to be able to format date/time input for my function.
Currently, I have a function that basically appends a 0 to a number if it is only 1 digit long.
def format_num(str(num)):
if len(num) < 2:
return "0" + num
return num
I was wondering if there was a more pythonic way to do this.