I recently came across this way of indexing a list in Python. I've never seen this one before, so I would like to understand this clearly.
I have a list ["Peter", "James", "Mark"]
and if I index it using the boolean value False
it returns Peter
and if I index it using True
it returns James
, as given below
["Peter", "James", "Mark"][False] => Peter
["Peter", "James", "Mark"][True] => James
I would like to know what happens here and what is this method called as?