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 वाचायला सोपा.