Jul-23-2018, 08:13 AM
(Jul-21-2018, 01:16 AM)WolfWayfarer Wrote: @perfringo: we're not allowed to use the calendar module, we have to do it "manually" so yeah, we're asked to invent the wheel although cars exist. I'm not against that, it's just that I really had no clue how to do it.
If it's all about not using proper tools then I would suggest to blow your teachers mind with following Monty-liner*:
year = 2014 months = sum([[[31, 30][i <= 6 and i % 2 == 0 or i > 7 and i % 2 != 0] if i / 2 != 1 else [28, 29][year % 4 == 0]] for i in range(1, 13)], [])months value will be:
Output:[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
it works with leap years, so year = 2016
value will be:Output:[31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
* Monty is Python's evil twin and his mission is to oppose Zen of Python whenever possible and abuse Python syntax.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.