Tag: lists
python lists, lists in python, python
Lists is a sequence and a basic data structure. A list may contain strings (text) and numbers. A list is similar to an array in other programming languages, but has additional functionality.
Related Course:
Python Programming Bootcamp: Go from zero to hero
Python List
We define lists with brackets []. To access the data, these same brackets are used.
Example list usage:
#!/usr/bin/python |
Add/remove
We can use the functions append() and remove() to manipulate the list.
#!/usr/bin/python |
Sort list
We can sort the list using the sort() function.
#!/usr/bin/python |
If you want to have the list in descending order, simply use the reverse() function.
#!/usr/bin/python |
If you are new to Python programming, I highly recommend this book.