I want to know something like,
weeks = '2 Weeks'
months = '1 Months'
if weeks < months:
print(f'{weeks} is less than {months}')
else:
print(f'{weeks} is greater than {months}')
so in the string, it only compares the numbers in the string. So it is printing "2 Weeks is greater than 1 Month". If I increase the value from '1 Month' to '3 Months' it then printing "2 Weeks is less than 3 Months". How can it detect itself to make the correct comparison?
datetime.timedeltaclass can handle hours, days, and weeks.