When I was just starting out with Python I found the distinction between a function doing something in place and returning the result instead pretty interesting.
Understanding this distinction is pretty important as a beginner! Since sorting in one of the most important operations we do in programming, let's look at an example involving exactly that.
➡ sorted([a_list]): is a built-in function than returns a new sorted list, without modifying the original
➡ a_list.sort(): sorts the list in place and doesn't return anything
Found it useful? Subscribe to my Analytics newsletter at notjustsql.com.