# P3.3 Python String Methods: strip, lower, upper, replace, split

Source: https://ravindrabagale.com/mr/datascience/py03-python-strings-tutorial-slicing-f-strings-and-string-methods/p3-3-python-string-methods-strip-lower-upper-replace.html
Language: mr (Marathi with English technical terms)

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

Data मधला text गोंधळलेला असतो: जास्तीच्या spaces, वेगवेगळं case, ₹ आणि commas. Methods ने तो एका line मध्ये साफ होतो.

हे काय आहे?

strip() कडेच्या spaces काढतो, lower()/upper()/title() case बदलतात, replace() text बदलतो आणि split() text चे तुकडे करून list देतो. Methods मूळ string बदलत नाहीत, नवीन देतात.

कसं करायचं?

Step 1. आधी strip() करा.
Step 2. मग case एकसारखा करा.
Step 3. नको असलेली चिन्हं replace() ने काढा.
Step 4. गरज असेल तर split() करा.

उदाहरण A: Spaces आणि case साफ करा

```python
city = "   CHENNAI  "
clean = city.strip().title()
print(clean)
```

Output:

```text
Chennai
```

याचा अर्थ: strip() ने कडेच्या spaces गेल्या आणि title() ने नाव नीट case मध्ये आलं.

उदाहरण B: पैशांची value साफ करा

```python
raw = "R 12,450.00"
num = float(raw.replace("R", "").replace(",", "").strip())
print(num)
```

Output:

```text
12450.0
```

याचा अर्थ: ₹ आणि commas काढून float() केल्यावर number मिळाला.

उदाहरण C: पूर्ण नाव आणि email split करा

```python
full = "Sofia Garcia Lopez"
parts = full.split(" ")
print(parts)
print(parts[0])
email = "sofia@example.com"
print(email.split("@")[1])
```

Output:

```text
['Sofia', 'Garcia', 'Lopez']
Sofia
example.com
```

याचा अर्थ: split() ने list मिळते. Email "@" वर कापलं की username आणि domain वेगळे होतात.

उदाहरण D: List परत text मध्ये जोडा

```python
tags = ["organic", "fresh", "local"]
print(", ".join(tags))
```

Output:

```text
organic, fresh, local
```

याचा अर्थ: ", ".join(list) सगळे items एका text मध्ये जोडतो.

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

Strings जागेवर बदलत नाहीत. `city.strip()` नवी string देतो; ती ठेवायला `city = city.strip()` लिहा.
