Lists in python - tasks and answers
List is a collection in python which is ordered and values inside list can be changed. List can hold all datatypes. To get values from list we can use indexing.
Here are some examples, how we can create a list
Create an empty list
Here are some examples, how we can create a list
Create an empty list
my_list = []
my_list1 = [1,2,3,4,5,6,7,8] # Creates a list of numbers
my_list2 = ["python", "html", "css"] # Creates a list of string
my_list2 = [True, False, True] # Creates a list of boolean
We can also create a list containing values different data types.
my_list = [1, "python", True, 5.6]
List Methods
- append
- clear
- copy
- count
- extend
- index
- insert
- pop
- remove
- reverse
- sort
No comments