Nov. 23, 2023, 6:42 a.m.
List is versatile data type available in Python. It is a sequence in which elements are written as a list of comma-separated values (items) between square brackets.
The key feature of a list is that it can have elements belong to different data types.
List is versatile data type available in Python. It is a sequence in which elements are written as a list of comma-separated values (items) between square brackets.
The key feature of a list is that it can have elements belong to different data types.
1. Lists are ordered collection of data items.
2. It can store multiple items in a single variable.
3. Lists items are separated by commas and enclosed with square brackets. []
4. Lists are changeable. We can alter them after creation.
# List of marks
marks= [23,34,56,78,23,90,83]
print(marks)
print(marks[0])
for i in marks:
print(i,end=" ")
print("\n")
for i in range(len(marks)):
print(marks[i],end=" ")
Output:
[23, 34, 56, 78, 23, 90, 83]
23
23 34 56 78 23 90 83
23 34 56 78 23 90 83
Click Here for more details