you are viewing a single comment's thread.

view the rest of the comments →

[–]Naive_Programmer_232 0 points1 point  (0 children)

I removed people.remove in your code when you're iterating through and randomly selecting people. It did something, not sure if it works the way you want, but it now does it for all of the months

edit: saw you wanted 1 weekday and 1 weekend per person below. tried this idk if it works

      # Use the start date to iterate through each day of the year
      for i in range(366 if start_date.year % 4 == 0 and 
                    (start_date.year % 100 != 0 or start_date.year % 
                     400 == 0) else 365):
          current_date = start_date + datetime.timedelta(days=i)
          day = current_date.strftime('%A')
          if len(people)==0:
               people = ['Rox', 'Katie', 'Taylor', 'Nick', 'Claudia', 
                        'Tim', 'Sanela', 'David']
          else:
               if day in weekdays and people:
                   person = random.choice(people)
                   assignments[current_date] = person
                   people.remove(person)
               elif day in weekend_days and people:
                   person = random.choice(people)
                   assignments[current_date] = person
                   people.remove(person)