I have a List:
DUP1 DUP1 DUP1 DUP1 DUP1 DUP2 DUP2 DUP2DUP2 JUMPDEST JUMPDEST JUMPDEST
I want to replace, DUP1 and DUP2 with DUP and similarly other matching strings with their sub strings.
I have written the following code:
changeOpcodes= ["DUP", "SWAP", "PUSH"]
lengthOfOpcodeList = len(opcodeList)
for x in range(1,lengthOfOpcodeList):
str = opcodeList[x]
if (str.find(changeOpcodes[0]) >0):
print("Str0 =", str)
opcodeList[x] = changeOpcodes[0]
elif (str.find(changeOpcodes[1]) >0):
print("Str1 =", str)
opcodeList[x] = changeOpcodes[1]
elif (str.find(changeOpcodes[2]) >0):
print("Str0 =", str)
opcodeList[x] = changeOpcodes[2]
Right now I am not getting any error but code is not executing the statements:
opcodeList[x] = changeOpcodes[0]
or
opcodeList[x] = changeOpcodes[1]
or
opcodeList[x] = changeOpcodes[2]
Thus when I am printing the list:
for w in opcodeList:
print(w)
I am still getting DUP1, DUP2, DUP3,…SWAP1, SWAP2,…PUSH1, PUSH2,…
Somebody please guide me.
Zulfi.