I have a code where I pass a value in whichweek and then it returns the values of dayfand dayt I am using the if statement but it's pretty long and it doesn't feel "pythonic" at all. Is there any elegant way to write this?
here is the way I do it:
if whichweek == 5:
dayf = 0
dayt = 32
elif whichweek == 1:
dayf = 0
dayt = 8
elif whichweek == 2:
dayf = 7
dayt = 15
elif whichweek == 3:
dayf = 14
dayt = 22
elif whichweek == 4:
dayf = 21
dayt = 29
Thanks for help.
Aucun commentaire:
Enregistrer un commentaire