Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97790

(Python)My list is getting cleared though I'm not clearing it[SOLVED]

$
0
0

I'm trying to append a temporary list(temp) to the main list(dfl) where the temporary list changes the elements inside it each iteration of a for loop. The code snippet is below-

for i in range(1,n+1):#n is the number of rows
    for j in range(2,8):
        data = driver.find_element_by_xpath("//xpath").text #Data is derived from a website element by element
        temp.append(data)
    dfl.append(temp)
    print(dfl)
    temp.clear()

Now, the print(dfl)gets me the desired output, [[list1],[list2]]. But when I execute the same print(dfl) outside the for loop, its printing out two empty lists like so [[],[]]

Can anyone find where I'm going wrong?


Viewing all articles
Browse latest Browse all 97790

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>