185k views
20 votes
What will be the value of the variable list2 after the following code executes? list1 = [1, 2, 3] list2 = [] for element in list1: list2.append(element) list1 = [4, 5, 6]

User Hzhu
by
4.4k points

1 Answer

8 votes

list1 = [1, 2, 3] list2 = [] for element in list1: list2.append(element)

User Taro Sato
by
3.6k points