Why do I get a ValueError
My current code raises following error:
return convert.strftime("%-d %B %Y year %-H {hour} %-M {minute}") ValueError: Invalid format string
My Code:
def date_time(time_input: str) -> str: hour = "hours" minute = "minutes" convert = datetime.datetime.strptime(time_input, "%d.%m.%Y %H:%M") if convert.hour == 1: hour = "hour" if convert.minute == 1: minute = "minute" return convert.strftime(f"%-d %B %Y year %-H {hour} %-M {minute}")
But why ?!