squares=[8,7,3,-1]
Print(squares[0])
The output of this program is 8 but I don't understand why? and what is this program do?
squares=[8,7,3,-1]
Print(squares[0])
The output of this program is 8 but I don't understand why? and what is this program do?
squares=[8,7,3,-1]
This create a list of 4 elements : 8, 7, 3 and -1.
Print(squares[0])
The print function will display a value. In your case it display the value squares[0]. Your list named squares have 4 values with indexes starting from 0, so :
Print(squares[0]) : 8
Print(squares[1]) : 7
Print(squares[2]) : 3
Print(squares[3]) : -1
Just look how list works in python to learn more.
This program creates a list called "squares" and then prints the first element of the list, which is 8. Pyhton uses 0-based indexing, so the first position of an iterable is 0.