title: Beginning date is bigger than the end date of a calendaristic period
body: <p>I am trying to write a function that validates a package that contains 2 dates (beginning and end), a destination and a price</p>
  <p>Initially, I tried to write a function that &quot;creates&quot; dates and puts them in a list and then compares them to find out if the end date was lower than the beginning but I figured that was too complicated so I resorted to the <code>datetime</code> inbuilt module</p>
  <p>However, when I try to run the test function, it fails and it outputs this error message</p>
  <pre><code>File &quot;C:\Users\Anon\Desktop\Fac\FP\pythonProject\main.py&quot;, line 65, in valideaza_pachet
      raise Exception(err)
  Exception: wrong dates!
  </code></pre>
  <p>I assume that I must have messed up a condition in the <code>valideaza_pachet()</code> function, but I don't understand what I did wrong</p>
  <p>The code:</p>
  <pre><code>import time
  import calendar
  from datetime import date, datetime
  
  
  def creeaza_pachet(data_i, data_s, dest, pret):
      # function that creates a tourism package, data_i = beginning date, data_s = end date, dest = destination and pret = price
      return {
          &quot;data_i&quot;: data_i,
          &quot;data_s&quot;: data_s,
          &quot;dest&quot;: dest,
          &quot;pret&quot;: pret
      }
  
  
  def get_data_i(pachet):
      # functie that returns the beginning date of the package
      return pachet[&quot;data_i&quot;]
  
  
  def get_data_s(pachet):
      # functie that returns the end date of the package
      return pachet[&quot;data_s&quot;]
  
  
  def get_destinatie(pachet):
      # functie that returns the destination of the package
      return pachet[&quot;dest&quot;]
  
  
  def get_pret(pachet):
      # functie that returns the price of the package
      # input: pachet - un pachet
      # output: pretul float &gt; 0 al pachetului
      return pachet[&quot;pret&quot;]
  
  
  def valideaza_pachet(pachet):
      #functie that validates if a package was correctly introduced or not
      #it raises an Exception as ex if any of the conditions aren't met
      err = &quot;&quot;
      if get_data_i(pachet) &lt; get_data_s(pachet):
          err += &quot;wrong dates!&quot; # if the end date is lower than the beginning date
      if get_destinatie(pachet) == &quot; &quot;:
          err += &quot;wrong destination!&quot;
      if get_pret(pachet) &lt;= 0:
          err += &quot;wrong price!&quot;
      if len(err) &gt; 0:
          raise Exception(err)
  
  
  def test_valideaza_pachet():
      pachet = creeaza_pachet(datetime.strptime('24/08/2021',&quot;%d/%m/%Y&quot;), datetime.strptime('26/08/2021',&quot;%d/%m/%Y&quot;), &quot;Galati&quot;, 9000.1)
      valideaza_pachet(pachet)
      pachet_gresit = creeaza_pachet(datetime.strptime('24/08/2021',&quot;%d/%m/%Y&quot;), datetime.strptime('22/08/2021',&quot;%d/%m/%Y&quot;), &quot;Galati&quot;, 9000.1)
      try:
          valideaza_pachet(pachet_gresit)
          assert False
      except Exception as ex:
          assert (str(ex) == &quot;wrong dates!\n&quot;)
      alt_pachet = creeaza_pachet(datetime.strptime('24/08/2021',&quot;%d/%m/%Y&quot;), datetime.strptime('22/08/2021',&quot;%d/%m/%Y&quot;), &quot; &quot;, -904)
      try:
          valideaza_pachet(alt_pachet)
          assert False
      except Exception as ex:
          assert(str(ex) == &quot;wrong dates!\nwrong destination!\nwrong price!\n&quot;)
  
  
  def test_creeaza_pachet():
      data_i_string = '24/08/2021'
      data_i = datetime.strptime(data_i_string, &quot;%d/%m/%Y&quot;)
      data_s_string = '26/08/2021'
      data_s = datetime.strptime(data_s_string, &quot;%d/%m/%Y&quot;)
      dest = &quot;Galati&quot;
      pret = 9000.1
      pachet = creeaza_pachet(data_i,data_s,dest,pret)
      assert (get_data_i(pachet) == data_i)
      assert (get_data_s(pachet) == data_s)
      assert (get_destinatie(pachet) == dest)
      assert (abs(get_pret(pachet) - pret) &lt; 0.0001)
  
  
  def run_teste():
      test_creeaza_pachet()
      test_valideaza_pachet()
  
  
  def run():
      pass
  
  
  def main():
      run()
      run_teste()
  
  
  main()
  </code></pre>