PYTHON-SET

Welcome to your PYTHON-SET

What is the difference between add() and update() functions in set?
How will you use remove function in Python?
How will you use discard function in Python?
Write a program to eliminate duplicates present in the list?Add description here!
A set contains names which begin either with A or with B. write a program to separate out the names into two sets, one containing names beginning with A and another containing names beginning with B.

# Split given set into two sets

lst = {'Adi', 'Amit', 'Amar', 'Babu', 'cat', 'baba', 'baat'}

x = set()

y = set()

for item in lst:

  if item.startswith('A'):

     x.add(item)

  elif item.startswith('B'):

     y.add(item)

print(x)

print(y)

What is the difference between the two set functions— discard() and remove()
How will you remove all duplicate elements present in a strings = 'vikas'
How will you remove all duplicate elements present in a list?

Author: CloudVikas