+ 3

Why printing(num.pop()) returns the index 0 and num=num.pop() removes index 0 from set?

Pop method behavior

10th Aug 2016, 2:44 AM
Jose Altagracia
Jose Altagracia - avatar
2 Answers
+ 4
Now I see. num.pop() removes index 0 from set and stores the new set in place. In other hand, num=num.pop() stores the item being removed. Therefore it makes sense that print(nums.pop()) will print the item being poped as the set has not yet being updated. Now I wonder how can I do that within the print function.
10th Aug 2016, 2:50 AM
Jose Altagracia
Jose Altagracia - avatar
0
what do you want to do? if you want to print nums after poping, just do nums.pop () and then print (nums)
10th Aug 2016, 7:23 AM
‫Ido Tal
‫Ido Tal - avatar