ipdb> tps.keys()
dict_keys(['2017-01-01','2017-07-17'])
ipdb> start_date
'2017-05-22'
ipdb> [x for x in tps.keys() if x >= start_date]
*** NameError: name 'start_date' is not defined
ipdb> [x for x in tps.keys() if x >= '2017-05-22']
['2017-07-17']
Here, my list comprehension works fine when I compare elements of tps.keys()
with '2017-05-22'
but it gives me an error when I compare with start_date
, but start_date
is assigned to 2017-05-22
so I'm confused as to why this happens. Why is this the case?