Addresses incorrect array access in python