+ 2
Python : Can you explain me the working of set iteration ?
As Set is unindexed , how set checks if an item is present? How SET iterates through elements if it doesnt have index? Can you explain me what happens inside the working of iteration of Sets ?
8 Answers
+ 2
Thanks Gordon ...
But I would like to clarify about working of set iteration that happens inside computer...
As list uses index to iterate through elements ,
How does set iterate through elements without index ?
+ 2
Set is unordered.
+ 2
Here are 6 other ways to iterate over set
https://www.google.com/amp/s/www.geeksforgeeks.org/iterate-over-a-set-in-JUMP_LINK__&&__python__&&__JUMP_LINK/amp/
In terms of efficiency, simple is best.
+ 1
A set is used to know whether an object is in or not : it is not used to behave in the same way of a list.
A set is iterable because Python widely use iterable object : it is the only way to access to a set.
+ 1
Thanks Théophile
+ 1
Thanks Gordon
+ 1
Thank you very much Gordon