Error message:
alarm = f"{alarm_hour}:{alarm_minute:02}:{alarm_am_pm}"
ValueError: '=' alignment not allowed in string format specifier
I don't know why this code is giving the error as I have used the same before in the 's program and it's working fine. Here's the code.
TIME = f"{current_hour}:{current_minute:02}:{current_second} {am_pm}"
But whenever I remove :02 from alarm_minute it works as I wanted to show number in 2 digits. I'm confused what's wrong with the code. Both are almost identical but one is giving error other's don't.
Assuming you want to have the number formated as a two digit with leading 0 when its a single digit you can pass this with the letter d to let the fstring know you want to format as 2 digits leaded by 0. you can do similar with floats to print to x many decimal places.
num = 3
price = 4.9
print(f"{num:02d}, {price:.2f}")
OUTPUT
03, 4.90