Bumped into a programming issue that puzzles me a bit. Im parsing data and:
- add each relevant chunk to list1, append list1 to final_list. (for easy and neat future presentation)
- For next relevant piece of information I'm deleting the "old" information in list1 with *list1[:] = []
- append the new fresh information to list1, append list1 to final_list and voilà... I thought :)
All help appreciated!
Example:
final_list=[]
list1 = [1,2,3,4]
list2 = [5,6,7,8]
final_list.append(list1)
final_list.append(list2)
print final_list
list1[:] = []
print final_list
Example output
[[1, 2, 3, 4], [5, 6, 7, 8]]
[[], [5, 6, 7, 8]]
Sys.version
Python: 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)]