# P8.2 Data कामातले नेहमीचे Python Errors आणि उपाय

Source: https://ravindrabagale.com/mr/datascience/py08-python-errors-and-exceptions-try-except-finally-explained/p8-2-common-python-errors-in-data-work-and-their.html
Language: mr (Marathi with English technical terms)

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

तेच पाच-सहा errors पुन्हा पुन्हा येतात. ओळखले की लगेच सुटतात.

हे काय आहे?

TypeError म्हणजे चुकीच्या types चं काम, IndexError म्हणजे list च्या बाहेरचा index, ZeroDivisionError म्हणजे शून्याने भागाकार.

कसं करायचं?

Step 1. Error चं नाव वाचा.
Step 2. त्या प्रकारचा नेहमीचा उपाय वापरा.

उदाहरण A: TypeError

```python
qty = "3"
print(qty + 2)
```

Output:

```text
TypeError: can only concatenate str (not "int") to str
```

याचा अर्थ: Text आणि number जोडले. आधी type बदला.

उदाहरण B: IndexError

```python
days = ["Mon", "Tue", "Wed"]
print(days[4])
```

Output:

```text
IndexError: list index out of range
```

याचा अर्थ: List मध्ये नसलेला index मागितला. len() तपासा.

उदाहरण C: ZeroDivisionError

```python
revenue = 0
orders = 0
print(revenue / orders)
```

Output:

```text
ZeroDivisionError: division by zero
```

याचा अर्थ: शून्याने भाग दिला. आधी 0 आहे का ते तपासा.

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

Jupyter मध्ये NameError चा अर्थ बहुतेक वेळा kernel restart केला आणि आधीचे cells परत चालवले नाहीत. Run All वापरा.
