Jesse Davidson647 Points
.copy method issue
I understand that the .copy method makes copy of the existing list as this will prevent you from making changes to the existing list.
However, What I do not understand in the course material is that when he assigns the .pop method to the items then it does not remove the the first index (items.copy(0)) in the copied list. Instead, it stays there.
ef display_wishlist(display_name,wishes): items = wishes.copy() print(display_name + ":") suggested_gift = items.pop(0) print("=====>",suggested_gift,"<=====") for item in items: print("* " + item) print()
The printed out display_wishlist function was written out twice, but why does this not remove the first item in the copied list like it did in the existing list when the .copy method was not implemented.
Majid Bilal3,558 Points
Because Items get renewed every time the function is called,
items = wishes.copy()
this line refreshes items as we are reassigning it the copy of wishes.