Python Convert list to set

In this tutorial, we will see how to convert list to set.
You can use python set() function to convert list to set.It is simplest way to convert list to set.

As Set does not allow duplicates, when you convert list to set, all duplicates will be removed in the set.

Let’s understand with the help of example.

Output:

List of Students: [‘Mohan’, ‘John’, ‘Ramesh’, ‘Mohan’, ‘John’] Set of uniqueNames: {‘John’, ‘Ramesh’, ‘Mohan’}
List of Makrs: [8, 7, 6, 7, 8, 8, 7, 6, 7, 8, 9] Set of marks: {8, 9, 6, 7}

As you can see, set starts with open curly braces and ends with close with braces.

Was this post helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *