Return a list of weekdays, starting with given weekday

后端 未结 9 2331
情书的邮戳
情书的邮戳 2021-02-07 23:53

My task is to define a function weekdays(weekday) that returns a list of weekdays, starting with the given weekday. It should work like this:

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-08 00:21

    Hmm, you are currently only searching for the given weekday and set as result :) You can use the slice ability in python list to do this:

    result = days[days.index(weekday):] + days[:days.index(weekdays)]
    

提交回复
热议问题