I have a piece of code that I would like to re-write in order for it to be more effective. I am working in Python, and there is not switch-break statement like in Java, but I feel something of a similar structure would work. The piece of code in particular I am talking about is:
def update(arm, array1, array2, array3, array4, array5):
# If the array is empty, add a zero
if not array1:
array1.append(0)
if not array2:
array2.append(0)
if not array3:
array3.append(0)
if not array4:
array4.append(0)
if not array5:
array5.append(0)
In general, what is a good way to avoid writing a series of if-statements like this in Python while also going through and checking each of these arrays for this particular function?