I have a problem in my code.
I am trying to make a assambler for my own assambly language.
And in a for loop that reads the code and replaces a instruction the for loop does not end.
Here is the piece of code:
asm = ["DW,1,2,4,5"] #example
i = 0
b1 = asm #copy of asm
for item in asm: #loop trough asm
if item.split(",")[0] == "DW": #check if the item is the instruction DW
plist = item.split(",")[1:] #create a list of the item
for line in plist: #go trough the parameters of DW and insert them in to b1
b1.insert(i,"DB," + line)
i += 1
asm = b1
The code does not delete the DW instruction yet.
The contents of list asm after i do a keyboard interupt:
>>> asm
Squeezed text (8781 lines).
Somehow it appends to list asm. Any help would be appreciated.