What is the syntax to output list elements?

#to output whole list
<list name>

#to output one element
<list name>[<index of element>]

#to output a portion of list
<list name>[<start index, inclusive>:<end index, exclusive>]
#examples
>>> grades=[60,77,86,95]

>>> grades
[60, 77, 86, 95]

>>> grades[0]
60

>>> grades[0:1]
[60]

>>> grades[:4]
[60, 77, 86, 95]

>>> grades[0:]
[60, 77, 86, 95]

>>> [60,77,86,95][1]
77

 

Advertisements