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 পড়তে সহজ।