aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Brody Critchlow <[email protected]>2023-01-27 13:57:45 -0700
committerGravatar GitHub <[email protected]>2023-01-27 13:57:45 -0700
commit413cfd38d7e9af22f7428d3afd16faac63e67d77 (patch)
tree8a3213bc6b59d7118b2a76c672c42414cef7d3c8
parentClarify empty and why it errors. (diff)
Small Minimization Changes
-rw-r--r--bot/resources/tags/in-place.md8
1 files changed, 1 insertions, 7 deletions
diff --git a/bot/resources/tags/in-place.md b/bot/resources/tags/in-place.md
index 8c5df89c9..7782175a2 100644
--- a/bot/resources/tags/in-place.md
+++ b/bot/resources/tags/in-place.md
@@ -2,19 +2,13 @@
In programming, there are two types of operations: "out of place" and "in place". An "out of place" operation creates a new object, leaving the original object unchanged. An "in place" operation modifies the original object, without creating a new one. These operations return None explicitly.
-A common example of these different concepts is seen in the use of the methods `list.sort()` and sorted(...) in Python. Using `list.sort()` will modify the original list and return None, so attempting to access an element of the list after calling `sort()` will result in an error.
-
-For example, the following code will result in an error:
+A common example of these different concepts is seen in the use of the methods `list.sort()` and `sorted(...)`. Using `list.sort()` and attempting to access an element of the list after calling `sort()` will result in an error.
```py
a_list = [3, 1, 2]
a_new_list = a_list.sort() # This will be None
print(a_new_list[1]) # This will error because it is NoneType and not a list
-```
-On the other hand, using the function `sorted(...)` will return a new sorted list, leaving the original list unchanged. This means that if you expect the original list to be sorted, you will be disappointed with the result. For example, the following code will print 3 instead of 1:
-
-```py
a_list = [3, 1, 2]
sorted(a_list)
print(a_list[0]) # You may expect 1, but it will print 3