-2

So I have a school project and I need help with a part of my code. I need to be able to subtract the number that has been inputed with the number of days in a specific month but I am unsure of how to do so. Here is the part of my code:

days = int(birthdayd) - int(todayd)
while days < 0:
  day2 = day + ***days in month***
else:
  pass

1 Answers1

0

The function monthrange() can give the the number of days in the month, but you need to know the month and the year.

from calendar import monthrange
yr = 2022
mt = 3
num_days = monthrange(yr, mt)[1]