Suppose something like this:
if mylist[0] == 1 or mylist[12] == 2:
But I'm not sure that mylist[12]
will always be out of range. What to do to keep things simple and still check if an index exists? I would not like to do
if mylist[0] == 1:
As you get too many identical lines of code.
user975135
source share