Next useful Python feature is Set(). Set is another built-in data structure used for storing data (other 3 are List, Tuple and Dictionary).
A set is a collection which is unordered, unchangeable*, and unindexed.
The most important feature of Set() is that it does not allow duplicate values.
|
|
How it helped me?
In my Job-scraper, after analazing job’s keywords, I am appending the list of found keywords into a Job dictionary, but first I convert the list into a set:
|
|
This way I know all the values are unique which saves time when I’m analyzing the keywords in my next function as it doesn’t have to check duplicate values.
|
|
*Set items are unchangeable, but you can remove items and add new items.