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.

1
2
3
4
5
6
7
numbers = [1, 1, 2, 3, 4, 5, 5, 5, 6, 7]

my_set = set(numbers)

print(myset)

# {1, 2, 3, 4, 5, 6, 7}

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:

1
2
	# Append summary keywords as a set to remove duplicates
	'summary': set(rake.get_ranked_phrases()),

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.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
job = {
	'id': id,
	'title': title,
	'company': company,
	'salary': salary,
	
	# Append summary keywords as a set to remove duplicates
	'summary': set(rake.get_ranked_phrases()),
	
	'link': f'https://www.profesia.sk{link}',
}

*Set items are unchangeable, but you can remove items and add new items.