from datetime import datetime
a = datetime(year=2020, month=1, day=1, hour=9, minute=0, second=0)
b = datetime(year=2020, month=1, day=1, hour=12, minute=0, second=0)
c = datetime(year=2020, month=1, day=1, hour=18, minute=0, second=0)
if a < c < b:
print('In range')
else:
print('Out of range')