Δεν έχουν όλοι οι μήνες 31 μέρες. Επίσης θα πρέπει να λάβεις υπόψη και τα δίσεκτα χρόνια κτλ.
Anyhow, μια λύση σε Python
from datetime import date
from datetime import timedelta
from itertools import cycle
from typing import Generator
def daterange(start: date, end: date) -> Generator[date, None, None]:
return (start + timedelta(n) for n in range((end- start).days))
def print_shifts(workers: list[str], start_date: str, end_date: str) -> None:
start = date.fromisoformat(start_date)
end = date.fromisoformat(end_date)
for (worker, date) in zip(cycle(WORKERS), daterange(start, end)):
print(f"{date.isoformat()} - {worker}")
if __name__ == "__main__":
WORKERS = ["kostas", "manos", "andreas", "maria", "eleni"]
START_DATE = "2020-02-01"
END_DATE = "2020-03-01"
print_shifts(
workers=WORKERS,
start_date=START_DATE,
end_date=END_DATE,
)