I'm using python slicing to take elements from a list but don't know if there are going to be enough in there.
At the moment I'm doing this, which feels ugly:
if index + num_to_take > len(values):
bit = values[index: ]
else:
bit = values[index:index + num_to_take]
Is there a better way?