Python List
1. INTRODUCTION TO PYTHONβS LIST
1.1. What Is a List?
wrestlers = ['John Cena','Rock','Rick Flair','Goldberg']
print(wrestlers)['John Cena', 'Rock', 'Rick Flair', 'Goldberg']1.2. Indexing (Accessing Elements in a List)
wrestlers = ['John Cena','Rock','Rick Flair','Goldberg']
print(wrestlers[0])John Cenawrestlers = ['John Cena','Rock','Rick Flair','Goldberg']
print(wrestlers[0].upper())1.3. Position of Elements in the List
1.4. Using Individual Values from a List
2. CHANGING, ADDING, AND REMOVING ELEMENTS
2.1. Modifying Elements in a List
2.2. Adding Elements to a List
a. Appending Elements to the End of a List
b. Inserting Elements into a List
2.3. Removing Elements from a List
a. Removing an Item Using the del Statement
b. Removing an Item Using the pop() Method
c. Popping Items from any Position in a List
2.4. Removing an Item by Value
3. ORGANIZING A LIST
3.1. Sorting a List Permanently with the sort() Method
3.2. Sorting a List Temporarily with the sorted() Function
3.3. Printing a List in Reverse Order
3.4. Finding the Length of a List
3.5. IndexError
Last updated