YUNOVA · Python programming
Module 11: Comprehensions & Built-ins
Python me list comprehension
Key points
- List comprehension एक line में नयी list बना देती है।
- पहले काम लिखा जाता है, फिर for वाला हिस्सा।
- आख़िर में if लगाकर कुछ items छाँटे भी जा सकते हैं।
Python me map() aur filter() function
Key points
- map() हर item पर एक function चलाकर नयी values देता है।
- filter() सिर्फ़ वही items रखता है जिन पर शर्त सही बैठे।
- दोनों का नतीजा देखने के लिए list() लगाना पड़ता है।