I am new to Python. When I added a string with add()
function, it worked well. But when I tried to add multiple strings, it treated them as character items.
>>> set1 = {'a', 'bc'}
>>> set1.add('de')
>>> set1
set(['a', 'de', 'bc'])
>>> set1.update('fg', 'hi')
>>> set1
set(['a', 'g', 'f', 'i', 'h', 'de', 'bc'])
>>>
The results I wanted are set(['a', 'de', 'bc', 'fg', 'hi'])
Does this mean the update()
function does not work for adding strings?
The version of Python used is: Python 2.7.1