lists in python

PYTHON LISTS
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.
We define lists with brackets []. To access the data, these same brackets are used.
for Example:
l = [ "Drake", "Derp", "Derek", "Dominique" ] print(l) # prints all elements print(l[0]) # print first element print(l[1]) # prints second element
And
We can use the functions append() and remove() to manipulate the list.
Sort list
We can sort the list using the sort() function.
If you want to have the list in descending order, simply use the reverse() function.
Comments
Post a Comment