Skip to content

Commit 28c63f1

Browse files
committed
list.sort returns none
1 parent d4c028d commit 28c63f1

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

docs/datastructure.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ We can store anything in the list, so first we are going to add another list *b
6969
[45, 43624356, -3434, 1, 45, 23, 1, 111, [45, 56, 90]]
7070
>>> a[-1]
7171
[45, 56, 90]
72-
>>> a.extend(b) #To add the values of b not the b itself
72+
>>> a.extend(b) # To add the values of b not the b itself
7373
>>> a
7474
[45, 43624356, -3434, 1, 45, 23, 1, 111, [45, 56, 90], 45, 56, 90]
7575
>>> a[-1]
@@ -87,6 +87,9 @@ Above you can see how we used the *a.extend()* method to extend the list. To sor
8787
>>> a
8888
[-3434, 1, 1, 23, 45, 45, 45, 56, 90, 111, 43624356]
8989

90+
91+
.. note:: Remember that `sort` method does not return the sorted list, instead the list itself will be sorted. This is done to keep performance of the code in mind. More details can be found `here <https://docs.python.org/3/faq/design.html?highlight=walrus#why-doesn-t-list-sort-return-the-sorted-list>`_.
92+
9093
You can also delete an element at any particular position of the list using the del keyword.
9194

9295
::
@@ -506,5 +509,11 @@ changes the variable outside of the function.
506509
[1, 2, 4, 42]
507510

508511

512+
Create a calculator
513+
====================
509514

515+
Here is a small problem for you. You will have to use list, and dictionary to
516+
create a tool, which will take input like `(* (+ 3 4) 2)` and return the answer
517+
like `14`. The four valid operators are `+`, `-`, `/*`. Every operator will
518+
need two operands to work on. Another input `(* 2 3)` and the output is `6`.
510519

0 commit comments

Comments
 (0)