I have the next part of code in python:
for (script, location) in self.device.scripts:
How can I start to take elements from the second pair of the given list? And if that is possible where should I check if a second element exist?
I have the next part of code in python:
for (script, location) in self.device.scripts:
How can I start to take elements from the second pair of the given list? And if that is possible where should I check if a second element exist?
Just slice it.
for script, location in self.device.scripts[1:]:
pass
For your second question, you don't need to worry about any IndexError since slicing returns an empty list when it's out of range.
Use itertools.islice() to slice skipping the first.
from itertools import islice
for (script, location) in islice(self.device.scripts, 1, None):
pass # do stuff