+ 3
Why printing(num.pop()) returns the index 0 and num=num.pop() removes index 0 from set?
Pop method behavior
2 odpowiedzi
+ 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.
0
what do you want to do? if you want to print nums after poping, just do nums.pop () and then print (nums)