added set function example (#25103)

* added set function example

added one example that how we can convert list to set by set function

* Added formatting and code output
This commit is contained in:
Amoghmule
2018-12-16 08:45:53 +05:30
committed by Manish Giri
parent b9362d8674
commit 26c407b7cd

View File

@ -30,3 +30,12 @@ However, if elements are included within the curly brackets, then it would be ac
>>> type(example_set_2)
<class 'set'>
````
### Converting List to Set
If you want to convert a list to a set, you can do that by using the `set()` function. This will remove all duplicate values from the list.
```python
>>> a = [11,2,2,6,6,4,8,9,9,7]
>>> a = set(a)
>>> print(a) # {2, 4, 6, 7, 8, 9, 11}
```