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.Lists.md #61

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions 06.Lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -400,16 +400,16 @@ print(max(numbers)) # Output: 8

# Nope, won't work, don't even try to do this!
imposter_numbers = ['s', 15]
print(min(imposter_numbers))
print(max(imposter_numbers))
```

#### Output

```
8
Traceback (most recent call last):
File "<string>", line 2, in <module>
TypeError: '<' not supported between instances of 'list' and 'int'
File "<string>", line 6, in <module>
TypeError: '>' not supported between instances of 'int' and 'str'
```

## 4. Methods of Lists
Expand Down Expand Up @@ -437,7 +437,7 @@ These methods let you add elements to the list, either at the end, a specific po
| Method | Description | Example | Output |
|-----------------|----------------------------------------------------|---------------------------------|-------------------------------|
| `remove(x)` | Removes the first item from the list whose value is x. | `x.remove('a')` | `[1, 2, 3, 4]` |
| `pop([i])` | Removes the item at the given position in the list, and returns it. | `x.pop(1)` | `[1, 3, 4]` |
| `pop(i)` | Removes the item at the given position in the list, and returns it. | `x.pop(1)` | `[1, 3, 4]` |
| `clear()` | Removes all items from the list. | `x.clear()` | `[]` |


Expand Down Expand Up @@ -494,7 +494,7 @@ Kyiv
Washington
```

Don't forget to call variables which make sense for data scructures like in the examples above.
Don't forget to call variables which make sense for data structures like in the examples above.

### 5.2 Using `for index in range(len(list))`

Expand Down Expand Up @@ -652,7 +652,7 @@ Deep copying is more memory-intensive and can be slower for large lists. So use

List comprehensions provide a more readable and concise way to create lists by transforming each element of an iterable.

They can be used in place of for loops for simplicity and efficiency, particularly when you're applying a single, straightforward transformation or condition to each element. Btw, they work faster than default loops.
They can be used in place of `for` loops for simplicity and efficiency, particularly when you're applying a single, straightforward transformation or condition to each element. Btw, they work faster than default loops.

### 7.1 Syntax

Expand All @@ -664,7 +664,7 @@ They can be used in place of for loops for simplicity and efficiency, particular
[expression for item in iterable if condition]

# If-else clause
[if expression else expression for item in itreable]
[expression_1 if condition else expression_2 for item in itreable]
```

Basically it is the same as for loops and each `list comprehension` _can be rewriten_ into the `for` loop.
Expand Down Expand Up @@ -727,11 +727,11 @@ for i in range(5):
["even", "odd", "even", "odd", "even"]
```

But there is some known rules between programers where we <span style="color:green">should</span> or <span style="color:red"> shouldn't </span> use them.
But there are some rules known by programers about when we <span style="color:green">should</span> or <span style="color:red"> shouldn't </span> use them.

In some cases for simple operation it is a great tool which working much faster in terms of efficiency, but in other cases it can lead to unnecessary complexion which will result in bad maintainability and readability of the code.
In some cases for simple operations it is a great tool working much faster in terms of efficiency, but in other cases it can lead to unnecessary complexion which will result in bad maintainability and readability of the code.

Please, be careful using list comprehesnsions.
Please, be careful using list comprehensions.


### 7.2 For-Loop vs List Comprehension
Expand Down Expand Up @@ -818,7 +818,7 @@ print(split_list)

These methods are especially powerful when used together, allowing for back-and-forth transformations between `strings` and `lists`.

Sure, here's the corrected and reformatted list for your quiz:


## 9. Quiz

Expand Down Expand Up @@ -1143,4 +1143,4 @@ Enter the text: Please contact us at [email protected] or [email protected] fo
Extracted Emails: [email protected]; [email protected]
```

Don't forget that while designing your program, remember to create an interactive and user-friendly interface!
Don't forget that while designing your program, remember to create an interactive and user-friendly interface!