How to force countdays to calculate from a array from a range of 1-7 so lets say
its 21 it outputs tuesday if the input day is monday
Your code so far
count++
currentdate = weekdaysarray[count]
def weekdays ( weekday ):
index = days.index( weekday )
return list( days[index:] + days )[:7]
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36
I have a bit of trouble understanding what you want to do - if you speak “arrays” maybe an example with an array would be helpful
Though looking at your code, what you propably need is a “list-comprehension” - is a special Python syntax which creates a list with specific elements.
For example to create [1,2,3,4,5] you can use [i+1 for i in range(1,5)] → so you can use any operation for the item, while the “for...in...” can take any iterable object.
so lets say i have a list of weekdays
days = (‘Monday’, ‘Tuesday’, ‘Wednesday’, ‘Thursday’, ‘Friday’, ‘Saturday’, ‘Sunday’)
weekdaysarray = weekdays(day.title())
i get the weekday thats passed from calling add_time
def add_time(start, duration,day=None):
i count the number of days from between start and duration in days and i want that specific weekday
the problem is for example if the weekday is more than 6 , it freaks out
so is there a way to make 20-> 5 21 → 6 22-> 0 etc