How do I get elements that repeat in a for loop to a list where I can print them later in my code? For instance:
for fname in dirlist:
if fname.endswith(('.tgz','.tar')):
print fname
fname displays only all elements from dirlist only in a loop. I would like to view items in other areas of my code. I tried li = fname ... but there was only one element when there really are about 7 elements. Thank!
suffa source
share