What is List?
mylist = ["faras", "Tata", "Fauziah"]
- List is used to store some items into a variable.
- List is one of 4 data default in Python that is utilized to store group of data. The other 3 are Tuple, Set, and Dictionary. All with quality and different usage.
- List is created by using this symbol square brackets []
- Element from list can be organized in order, can be changed and may be a duplicate value. Element list is indexed. first item has index [0], second item has index [1], etc.
- When we say that the list is organized in order it means that the item has order that is determined and the order cannot be changed. If we want to add new item into list, new item will be placed in the end of list.
Note: There are few lists method to change order, but in common: element in order will never be changed.
- List can be changed (changeable), it means we can change, add and delete item in the list after creating it.
- Because list that is indexed, list can have item with the same value.
- List of elements can be any data type.
list1 = ["A", "B", "C"]
list2 = [1, 2, 3, 4, 5]
list3 = [True, False. False]
lists = ["MySkill", 25, False, 23, "student"]
What is List (2)?
mylist = list(("apps", "os", "version")) # must use double square brackets
print(mylist)
Enable also to use construction list () when we make new list.