List Collection:
- In python a list is a data structure that is a mutable, or changeable, ordered sequence of elements.
- Each element or value that is inside of a list is called an item.
- Strings and characters are indicated by single or double or triple quotes.
- List values are defined by between square brackets [ ] .
- In Python programming, a list is created by placing all elements inside square brackets [] , separated by commas.
- List can have number of elements and different types like integer, float, string etc.
Creating a List of numbers:
List2 = [40, 20, 14]
print(len(List2))
Example code:
my_list = []
my_list = [7, 8, 9]
my_list = [5, "Hello", 9.4]
Creating empty list:
List = []
print("Blank List: ")
print(List)
Creating a List of strings using index
List = ["Tutipy", "Tutorials", "For", “Learners”]
print("\nList Items: ")
print(List[0])
print(List[2])