← Learn to Code — Python for Beginners
मॉड्यूल · Put It Together
Lists
A list stores many values together, in order, under one name.
marks = [78, 85, 60, 92, 45]
print(marks[0])
print(marks[-1])
print(len(marks))
Python counts positions from 0, so marks[0] is the FIRST item, not the second. marks[-1] is a shortcut for "the last item."
You can loop over a list and do something with every item:
marks = [78, 85, 60, 92, 45]
total = 0
for m in marks:
total = total + m
print("Average:", total / len(marks))
Try it: the starter code below does exactly this — run it, then change the marks to your own.