Answers for "python declare set"

13

empty set python

# Distinguish set and dictionary while creating empty set

# initialize a with {}
a = {}

# check data type of a
print(type(a))

# initialize a with set()
a = set()

# check data type of a
print(type(a))
Posted by: Guest on May-24-2020
12

sets in python

The simplest way to create set is:
1. from list
code:
	s = [1,2,3]
	set = set(s)
	print(set)

2. s,add() method
code:
	set.add(1)
	set.add(2)
	set.remove(2)
	print(set)  // 1

3. Set conatins unique elements
Posted by: Guest on June-07-2020
0

python declare set

not_empty_set = set(("apple", "bananna", "cherry"))
empty_set = set()
Posted by: Guest on June-23-2021

Python Answers by Framework

Browse Popular Code Answers by Language