# P6.7 Python List Comprehension सोप्या भाषेत

Source: https://ravindrabagale.com/mr/datascience/py06-python-for-loops-and-while-loops-explained-with-examples/p6-7-python-list-comprehension-explained-simply.html
Language: mr (Marathi with English technical terms)

हे का शिकायचं?

Loop ने नवीन list बनवणं इतकं नेहमीचं आहे की Python मध्ये त्यासाठी एका line ची पद्धत आहे.

हे काय आहे?

[expression for x in list if condition] — loop, बदल आणि filter एकाच line मध्ये.

कसं करायचं?

Step 1. [ ] लिहा.
Step 2. आधी नवीन value, मग for, गरज असेल तर if.

उदाहरण A: एका line मध्ये prices convert

```python
usd = [10, 25, 40]
inr = [p * 83 for p in usd]
print(inr)
```

Output:

```text
[830, 2075, 3320]
```

याचा अर्थ: Loop + append चं काम एका line मध्ये झालं.

उदाहरण B: एका line मध्ये filter

```python
orders = [250, 800, 1200, 300, 650]
print([o for o in orders if o > 500])
```

Output:

```text
[800, 1200, 650]
```

याचा अर्थ: शेवटच्या if ने फक्त हवे ते items ठेवले.

उदाहरण C: एका line मध्ये नावं साफ

```python
raw = ["  pune", "MUMBAI ", "nagpur"]
print([c.strip().title() for c in raw])
```

Output:

```text
['Pune', 'Mumbai', 'Nagpur']
```

याचा अर्थ: प्रत्येक नावावर strip().title() लावलं.

रवींद्र बागले यांची tip

छोट्या, सोप्या कामांसाठी comprehensions वापरा. एकापेक्षा जास्त if लागले तर साधा loop लिहा.
