From 26c407b7cd152a4580382c34b4c6cdd65c514e85 Mon Sep 17 00:00:00 2001 From: Amoghmule Date: Sun, 16 Dec 2018 08:45:53 +0530 Subject: [PATCH] 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 --- guide/english/python/learn-about-python-sets/index.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/guide/english/python/learn-about-python-sets/index.md b/guide/english/python/learn-about-python-sets/index.md index 4b1c565b9d..cfdc838f09 100644 --- a/guide/english/python/learn-about-python-sets/index.md +++ b/guide/english/python/learn-about-python-sets/index.md @@ -30,3 +30,12 @@ However, if elements are included within the curly brackets, then it would be ac >>> type(example_set_2) ```` + +### 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} +```