Question: Complete the dbda() function. Given a starting date and a number of days, dbda() should call either before() or after() inside of a loop and

  1. Complete the dbda() function. Given a starting date and a number of days, dbda() should call either before() or after() inside of a loop and return the end date. A negative number of days should return a date before start_date, and a positive number should return a date after start_date.. 
  2. NOTE- THE SCRIPT BELOW IS MINE BUT WHEN I RUN MY CHECKING SCRIPT I GET AN ERROR. -  if int(str_date) >= 10:
    ValueError: invalid literal for int() with base 10: '2023-01-23'
     

def dbda(start_date: str, step: int) -> str:
   str_date = start_date

   if int(str_date) >= 10:
       for day in range(str_date):
           str_date = after(str_date)
   else:
       str_date = str_date * -1
       for date in range(str_date):
           str_date = before(str_date)

       end_date = str_date

       return end_date

   if __name__ == "__main__":

       if len(sys.argv) != 3:
         print("Use: assign1.py YYYY-MM-DD No")

   date = str(sys.argv[1])
   str_date = int(sys.argv[2])

   if valid_date(date):
     final_date = dbda(date,step)
     print(final_date)

Step by Step Solution

3.40 Rating (159 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

You are trying to convert the strdate to an integer but its a date in string format You should not c... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!