Aug-22-2019, 06:00 AM
Comprehension in Python is very simple and powerful feature. However, at the beginning it may seem like magic. One way of becoming wizard is to say in spoken language what comprehension does.
Simple example:
'give me number for every number in list which is even':
Simple example:
'give me number for every number in list which is even':
[num for num in [1, 2, 3, 4, 5] if not num % 2]To take it into pieces:
num
- give me a numberfor num in [1, 2, 3, 4, 5]
- for every number in listif not num % 2
- which is even
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.