How to Use Set Construct Method in PythonPython Basics


The operator {} or set() function can be used to create a set which is an unordered sequence without repeated elements.

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

temp_set= {'A', 'B', 'C', 'A', 'B', 'D'}
print(temp_set)

Output:

{'D', 'B', 'A', 'C'}

Syntax

parame = {value01,value02,value03,...}

Parameters

The method doesn’t take any parameters.

Return Value

The method doesn’t return any value.

© 2024 Learnwithgpt.org, all rights reserved. Privacy Policy | Contact Us