0

Am inserting the values using split, lstrip and strip from a line that am reading though a file and i insert them into 2 separate arrays. The so array has a problem, when am printing the values during the time of the computation all goes as plant, after I print the values again using a for loop i got only the last value of so[len][0] and the last values of so[len][1] as output through the whole array.

rows, cols = (80, 2)
so = [[0]*cols]*rows
N=80
de =[0 for i in range(N)]
while True:
    if "L2:" in line:
        while True:
            if "jmp" in line:
                break
            else:
                if line.startswith("\tv"):
                    x=line.split(",")
                    a=line.split(",")[1]
                    b=line.split(",")[2]
                    c=line.split(",")[0]
                    d=c.lstrip()
                    d=d.lstrip("vmultpdaxdorsub ")
                    so[len][0]=a
                    so[len][1]=d
                    b=b.strip()
                    de[len]=b
                    #print (str(line))
                    #print(str(so[len][0]))
                    #print(str(so[len][1]))
                    #print(de[len])
                    len+=1
                elif (line.startswith("\ta") or line.startswith("\tm") or line.startswith("\ti") or line.startswith("\te") or line.startswith("\tc") or line.startswith("\tj") or line.startswith("\t\tj")):
                    x=line.split(",")
                    a=line.split(",")[1]
                    c=line.split(",")[0]
                    d=c.lstrip()
                    d=d.lstrip('abcdefghigklmnopqrstuvwxyz ')
                    so[len][0]=d
                    a=a.strip()
                    de[len]=a
                    #print(str(line))
                    #print(str(so[len][0]))
                    #print(str(de[len]))
                    len+=1
                    
            line=r.readline()
    else:
        line=r.readline()
    if "jmp" in line:
        break
martineau
  • 112,593
  • 23
  • 157
  • 280
kolokasi
  • 23
  • 4
  • `so = [[0]*cols]*rows` is your problem. Try `[[0 for _ in range(cols)] for _ in range(rows)]` – dawg Feb 05 '22 at 18:31

0 Answers0