Lesson 27 of 34
List Comprehensions: ఒకే లైన్లో Lists
8 min 30 XP
loop తో list తయారు చేయడాన్ని ఒకే లైన్లో రాయవచ్చు: [expression for item in collection]. Python లో అందరికీ ఇష్టమైన ఫీచర్లలో ఇది ఒకటి.
Example: edit me and press Run
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.చివర if కలిపి సరిపోయే items ను మాత్రమే ఉంచండి (filter).
Example: edit me and press Run
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.dictionary comprehension కోసం { } వాడండి. comprehension మరీ పొడవైతే సాధారణ loop చదవడానికి సులభం.