# P3.5 in, startswith आणि endswith ने Text कसा तपासायचा?

Source: https://ravindrabagale.com/mr/datascience/py03-python-strings-tutorial-slicing-f-strings-and-string-methods/p3-5-how-to-check-text-with-in-startswith-and.html
Language: mr (Marathi with English technical terms)

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

Order cancel झाला का, email gmail चा आहे का, ID कोणत्या city चा आहे — असे प्रश्न text तपासून सुटतात.

हे काय आहे?

"x" in s शब्द आत आहे का सांगतो. s.startswith() सुरुवात आणि s.endswith() शेवट तपासतो. उत्तर True किंवा False येतं.

कसं करायचं?

Step 1. Case एकसारखा करा (lower()).
Step 2. in, startswith किंवा endswith वापरा.
Step 3. True/False वरून निर्णय घ्या.

उदाहरण A: शब्द आत आहे का?

```python
ticket = "Customer wants a refund for order 778"
print("refund" in ticket)
print("cancel" in ticket)
```

Output:

```text
True
False
```

याचा अर्थ: in ने True/False मिळालं. आधी lower() केलं म्हणून case चा फरक पडला नाही.

उदाहरण B: सुरुवात आणि शेवट तपासा

```python
code = "BLK-PUN-1001"
file = "sales_march.csv"
print(code.startswith("BLK"))
print(file.endswith(".csv"))
```

Output:

```text
True
True
```

याचा अर्थ: startswith ID ची city आणि endswith email चं domain तपासतो.

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

तपासण्याआधी दोन्ही बाजू lower case करा: `"refund" in text.lower()`. मग "Refund" आणि "REFUND" पण match होतात.
