Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 06_tuples.md #491

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion 06_Day_Tuples/06_tuples.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ len(tpl)
first_fruit = fruits[0]
second_fruit = fruits[1]
last_index =len(fruits) - 1
last_fruit = fruits[las_index]
last_fruit = fruits[last_index]
```

- Negative indexing
Expand Down Expand Up @@ -151,6 +151,13 @@ We can slice out a sub-tuple by specifying a range of indexes where to start and
orange_mango = fruits[-3:-1] # doesn't include item at index 3
orange_to_the_rest = fruits[-3:]
```
```py
fruits = ('mercedes', 'bmw', 'ferrari', 'buggati')
all_fruits = fruits[-4:] # all items
orange_mango = fruits[-3:-1] # doesn't include item at index 3
orange_to_the_rest = fruits[-3:]
```


### Changing Tuples to Lists

Expand Down
12 changes: 12 additions & 0 deletions 17_Day_Exception_handling/17_exception_handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ In the above example, the exception block will run and we do not know exactly th

In the following example, it will handle the error and will also tell us the kind of error raised.

```py
try:
a = input('Enter the value of A')
b = input('Enter the value of B')
print(f'Answer of A divide by B is {a/b}')
except ZeroDivisionError:
print('zero division error occured')

```



```py
try:
name = input('Enter your name:')
Expand Down