The Code does not go in the If Statement no matter what (where I intend to alter the array "dop", I have no idea why. Any Help will be appreciated
#The Array dop
dop = ["1878[1879]","1877","[2016]2015","1874","[2871]2987","3012[2019]"]
i = 0;
#Used Try Catch Block because of the Type Error that occurs when '[' is not found in an array
#Element
while(i < 6):
try:
strObject = dop[i]
print(strObject)
indexOne = strObject.index('[',0)
indexTwo = strObject.index(']',0)
print(indexOne)
print(indexTwo)
if (indexOne != 0 | indexOne != -1):
substringObject = strObject[0:indexOne]
dop[i] = substringObject
i = i+1
print(i)
elif (indexOne == -1):
i = i+1
elif (indexOne == 0):
substringObject = strObject[indexTwo]
dop[i] = substringObject
i = i+1
except ValueError:
print("Goes Here")
i = i+1
print(i)
i = i+1
Aucun commentaire:
Enregistrer un commentaire