So I am at my last assignment for the weekend. The assignment was to write a program that would add a number of hours to the current time and show when the alarm would go off. The program does what it should do, but the format the time is printed bothers me. I want it to be the same format as in my first line. I have tried to use “strftime” in the print command, but this gives an error message.
INPUT
import datetime
from datetime import timedelta
now = datetime.datetime.now().strftime(’%d-%m, %Hu%M’)
print(“It is now”, now)
alarm = int(input("In how many hours do you want the alarm to go off? "))
print(“Thanks,”)
print(“The alarm will go off in”, alarm, “hours.”)
print("It will then be " + str(datetime.datetime.now() + timedelta(hours=alarm)))
OUTPUT
It is now 31-01, 10u55
In how many hours do you want the alarm to go off? 3
Thanks
The alarm will go off in 3 hours.
It will then be 2021-01-31 13:55:36.666980
Any suggestion on how to solve this would be greatly appreciated!