IndexError: list index out of range
The message is telling you that the index value is greater than the number of items in the list. You should not make assumptions about the results of commands, but check first. If the returned list has only one item then you need to code for that.