Screen Link:
My Code:
for hour in sorted_swap[:5]:
hour = dt.datetime.strptime(hour[1], "%H")
hour = hour - dt.timedelta(hours = 1)
hour = hour.strftime("%H:%M")
print(
"{}: {:.2f} average comments per post ".format(
dt.datetime.strptime(hour, "%H").strftime("%H:%M")
)
)
What actually happened: Im stuck at this piece of code. I want to subtract 1 hour from EST time and not sure what should be passed in .format()
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-67-692188605763> in <module>
5 print(
6 "{}: {:.2f} average comments per post ".format(
----> 7 dt.datetime.strptime(hour, "%H").strftime("%H:%M")
8 )
9 )
/usr/local/lib/python3.8/_strptime.py in _strptime_datetime(cls, data_string, format)
566 """Return a class cls instance based on the input string and the
567 format string."""
--> 568 tt, fraction, gmtoff_fraction = _strptime(data_string, format)
569 tzname, gmtoff = tt[-2:]
570 args = tt[:6] + (fraction,)
/usr/local/lib/python3.8/_strptime.py in _strptime(data_string, format)
350 (data_string, format))
351 if len(data_string) != found.end():
--> 352 raise ValueError("unconverted data remains: %s" %
353 data_string[found.end():])
354
ValueError: unconverted data remains: :00
Please guide me where I'm going wrong