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 ಓದಲು ಸುಲಭ.