Answers for "for i in set python"

4

loop through set python

#Create a set 
num_set = set([0, 1, 2, 3, 4, 5])
for n in num_set:
  print(n)
Posted by: Guest on March-15-2020
13

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

Python Answers by Framework

Browse Popular Code Answers by Language