Skip to content

Commit

Permalink
second version tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
Asabeneh committed Jul 7, 2021
1 parent 543a95c commit 3b62f23
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions 05_Day_Lists/05_lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ all_fruits = fruits[0:4] # it returns all the fruits
all_fruits = fruits[0:] # if we don't set where to stop it takes all the rest
orange_and_mango = fruits[1:3] # it does not include the first index
orange_mango_lemon = fruits[1:]
orange_and_lemon = fruits[::2] # here we used a 3rd argument, step. It will take every 2cnd item - ['orange', 'lemon']
orange_and_lemon = fruits[::2] # here we used a 3rd argument, step. It will take every 2cnd item - ['banana', 'mango']
```

- Negative Indexing: We can specify a range of negative indexes by specifying the start, end and step, the return value will be a new list.
Expand Down Expand Up @@ -477,10 +477,10 @@ lst.reverse()
```py
fruits = ['banana', 'orange', 'mango', 'lemon']
fruits.reverse()
print(fruits.reverse()) # ['lemon', 'mango', 'orange', 'banana']
print(fruits) # ['lemon', 'mango', 'orange', 'banana']
ages = [22, 19, 24, 25, 26, 24, 25, 24]
ages.reverse()
print(ages.reverse()) # [24, 25, 24, 26, 25, 24, 19, 22]
print(ages) # [24, 25, 24, 26, 25, 24, 19, 22]
```

### Sorting List Items
Expand Down
11 changes: 5 additions & 6 deletions 06_Day_Tuples/06_tuples.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@

<sub>Author:
<a href="https://www.linkedin.com/in/asabeneh/" target="_blank">Asabeneh Yetayeh</a><br>
<small> First Edition: Nov 22 - Dec 22, 2019</small>
<small> Second Edition: July, 2021</small>
</sub>

</div>
</div>

[<< Day 5](../05_Day_Lists/05_lists.md) | [Day 7 >>](../07_Day_Sets/07_sets.md)
Expand All @@ -26,7 +25,7 @@
- [Accessing Tuple Items](#accessing-tuple-items)
- [Slicing tuples](#slicing-tuples)
- [Changing Tuples to Lists](#changing-tuples-to-lists)
- [Checking an Item in a List](#checking-an-item-in-a-list)
- [Checking an Item in a Tuple](#checking-an-item-in-a-tuple)
- [Joining Tuples](#joining-tuples)
- [Deleting Tuples](#deleting-tuples)
- [💻 Exercises: Day 6](#-exercises-day-6)
Expand Down Expand Up @@ -115,7 +114,7 @@ len(tpl)

### Slicing tuples

We can slice out a subtuple by specifying a range of indexes where to start and where to end in the tuple, the return value will be a new tuple with the specified items.
We can slice out a sub-tuple by specifying a range of indexes where to start and where to end in the tuple, the return value will be a new tuple with the specified items.

- Range of Positive Indexes

Expand Down Expand Up @@ -170,9 +169,9 @@ fruits = tuple(fruits)
print(fruits) # ('apple', 'orange', 'mango', 'lemon')
```

### Checking an Item in a List
### Checking an Item in a Tuple

We can check if an item exists or not in a list using _in_, it returns a boolean.
We can check if an item exists or not in a tuple using _in_, it returns a boolean.

```py
# Syntax
Expand Down

0 comments on commit 3b62f23

Please sign in to comment.