I have this function that iterates through arrays, makes the arrays smaller and does operations with the arrays when they're at certain lengths based on their entries. For some reason, the bolded section with the "print("xxx")" statement continues to run even when the length of the array is not equal to 4.
def DimItt(Arr):
x = Arr[0]
print(Arr)
for i in range(len(Arr)):
if Arr[len(Arr) - 1] != 0:
break
if Arr[len(Arr) - 1] == 0:
del Arr[len(Arr) - 1]
if len(Arr) == 2:
print("www")
if Arr[1] != 0:
for i in range(Arr[1]):
x += 1
if len(Arr) == 4:
for i in range(x):
for j in range(len(Arr) - 1):
Arr[j] = x
print("xxx")
print(len(Arr))
Arr[len(Arr) - 1] -= 1
x = DimItt(Arr)
if len(Arr) == 1:
print("yyy")
x = Arr[0]
return x
return x
print(DimItt([7, 25, 3, 2, 0, 0]))
Aucun commentaire:
Enregistrer un commentaire