From fec253d0f0125e0888ba5a1b66e0fd2dd6547845 Mon Sep 17 00:00:00 2001 From: tteodorescu0 Date: Fri, 21 Jun 2024 22:13:55 -0400 Subject: [PATCH] Update 06.Lists.md Mostly typos --- 06.Lists.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/06.Lists.md b/06.Lists.md index 7200128..1541c7b 100644 --- a/06.Lists.md +++ b/06.Lists.md @@ -400,7 +400,7 @@ 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 @@ -408,8 +408,8 @@ print(min(imposter_numbers)) ``` 8 Traceback (most recent call last): - File "", line 2, in -TypeError: '<' not supported between instances of 'list' and 'int' + File "", line 6, in +TypeError: '>' not supported between instances of 'int' and 'str' ``` ## 4. Methods of Lists @@ -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()` | `[]` | @@ -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))` @@ -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 @@ -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. @@ -727,11 +727,11 @@ for i in range(5): ["even", "odd", "even", "odd", "even"] ``` -But there is some known rules between programers where we should or shouldn't use them. +But there are some rules known by programers about when we should or shouldn't 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 @@ -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 @@ -1143,4 +1143,4 @@ Enter the text: Please contact us at support@example.com or sales@example.com fo Extracted Emails: support@example.com; sales@example.com ``` -Don't forget that while designing your program, remember to create an interactive and user-friendly interface! \ No newline at end of file +Don't forget that while designing your program, remember to create an interactive and user-friendly interface!