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 വായിക്കാൻ എളുപ്പമാണ്.