We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
1 parent52073d8 commit93a00c2Copy full SHA for 93a00c2
basics/lists-and-tuples.md
@@ -142,7 +142,7 @@ We'll talk more about loops [in the next chapter](loops.md).
142
```
143
144
Another useful things about list is**comprehension**.
145
-**Comprehension** is a way toloop the list in single line. It makes our code morepythonic.
+**Comprehension** is a way toconstruct a list in single line. It makes our code moreclean, shorter and easier to read.
146
147
```python
148
>>> numbers= [1,2,3,4,5]
@@ -152,6 +152,18 @@ Another useful things about list is **comprehension**.
152
>>>
153
154
155
+without comprehension:
156
+
157
+```python
158
+>>> numbers= [1,2,3,4,5]
159
+>>> numbers_squared= []
160
+>>>for numberin numbers:
161
+... numbers_squared.append(number**2)
162
+>>> numbers_squared
163
+[1,4,9,16,25]
164
+>>>
165
+```
166
167
We can also use slicing and indexing to change the content:
168
169