What is the difference between add and update operations in python if i just want to add a single value to the set.
a = set() a.update([1]) #works a.add(1) #
We use add() method to add single value to a set.
add()
We use update() method to add sequence values to a set.
update()
Here Sequences are any iterables including list,tuple,string,dict etc.
list
tuple
string
dict