title: How to calculate the number of days left in a given year without using the datetime module?
body: <p>I am stuck on trying to get the number of days remaining in a given year.</p>
  <p>I have already defined a function that determines whether the year is a leap year and how many days in a given month. However, I'm stuck a defining the last function without using the datetime module.</p>
  <pre><code>year = int(input(&quot;Enter the year to determine the number of days: &quot;))
  month = int(input(&quot;Enter the month of the year: &quot;))
  day = int(input(&quot;Enter the day of the year: &quot;))
  
  def if_leap_year(year):
  
      if (year % 400 == 0): return 366
      
      elif (year % 100 == 0): return 365
      
      elif (year % 4 == 0): return 366
  
      else:
          return 365
  
  print(if_leap_year(year))
  
  def days_in_month(month, year):
      if month in {1, 3, 5, 7, 8, 10, 12}:
          return 31
      if month == 2:
          if if_leap_year(year):
              return 29
          return 28
      return 30
  
  print(days_in_month(month, year))
  
  
  def days_left_in_year(month, day, year):
      month2 = 12
      day2 = 31
      day = day2 -365
  </code></pre>
  <p>I am stuck at this very last part... any help would be appreciated.</p>
  <p>Edit:
  So now that I have:</p>
  <pre><code>    def days_left_in_year(month, day, year):
          daysInMonth = [31,28,31,30,31,30,31,31,30,31,30,31]
          daysLeft = (if_leap_year(year) if month &lt; 3 else 365) - sum(daysInMonth[:month - 1]) - day
          return daysLeft
  </code></pre>
  <p>I want to use all of these 3 functions to create the output similar to:</p>
  <p>When did you cancel your Subprime service?</p>
  <p>Month: 2</p>
  <p>Day: 29</p>
  <p>Year: 2021</p>
  <p>Sorry, 2/29/2021 doesn’t appear to be a valid date. Care to try again?</p>
  <p>Month: 2</p>
  <p>Day: 29</p>
  <p>Year: 2020</p>
  <p>I tried using:</p>
  <pre><code>def refund_period():
      year = int(input(&quot;Enter the year to determine the number of days: &quot;))
      month = int(input(&quot;Enter the month of the year: &quot;))
      day = int(input(&quot;Enter the day of the year: &quot;))
      if if_leap_year(year) == 365:
          money_owed = (days_left_in_year(month, day, year) / 365) * 278
      if if_leap_year(year) == 366:
          money_owed = (days_left_in_year(month, day, year) / 366) * 278
  </code></pre>
  <p>But money_owed is not called, so now I am stuck yet again.... :(</p>