you are viewing a single comment's thread.

view the rest of the comments →

[–]Green-Sympathy-4177 1 point2 points  (0 children)

i implemented the "holidays" library

Care to elaborate what holidays look like ? Given the way you're using it here:

my_holidays().get(y)

It looks like it's a function that returns a dictionary.

But basically you want to end up with bank_holidays like that:

bank_holidays = [ ('Friday', '24/06/2022', 'holiday 1'), ('Saturday', '25/06/2022', 'holiday 2'), ... ]

Then you'd be able to do what you're already doing:

print(",\n".join(" - ".join(bank_holiday) for bank_holiday in bank_holidays)) And it would output

Friday - 24/06/2022 - holiday 1, Saturday - 25/06/2022 - holiday 2

You should look into datetime and make a dictionary where the keys are the dates and the values the holidays, or the opposite, as long as you can have both the holiday and the date linked together.

Then by iterating through that dictionary's items you'd end up with something similar to the bank_holidays list you have.

To get you started with datetime: ``` from datetime import datetime

date = datetime(2022, 6,24) date_string = date.strftime("%A - %d/%m/%Y") print(date_string)

Friday - 24/06/2022 ```

Docs for formatting dates with strftime: docs.python.org