Functions and methods · Python Comparisons
Functions that seem interchangeable often differ in what they return or whether they change the original data. These comparisons show the exact difference with a table and runnable code.
All 6
Python append() vs extend(): What Is the Difference?
`append(x)` adds **one** item to the end of a list (even if it is a list), while `extend(iterable)` adds **each element** of an i…
Python sort() vs sorted(): What Is the Difference?`list.sort()` sorts a list **in place** and returns `None`, while `sorted(iterable)` leaves the original untouched and **returns …
Python remove() vs pop() vs del: What Is the Difference?`remove(x)` deletes the first item **equal to a value**, `pop(i)` deletes the item at an **index and hands it back**, and `del` i…
Python print() vs return: What Is the Difference?`print()` **displays** a value on the screen and gives you nothing to work with, while `return` **sends a value back** to the cod…
Python str() vs repr(): What Is the Difference?`str()` returns a **readable** version of an object meant for users, while `repr()` returns an **unambiguous** version meant for …
Python Deep Copy vs Shallow Copy: What Is the Difference?A **shallow copy** makes a new outer container but still shares the inner objects with the original, while a **deep copy** recurs…
Explore more
Python ReferencePython ProgramsPython How-To GuidesPython Cheat SheetsPython glossaryPython tutorial