clear() method for set

All set methods

clear() takes no argument.

Returns : No return value.
my_set={'a','b','c','d','e'}
my_set.clear()
print(my_set)
Output is here
set()

del and clear() difference

We can use keyword del to remove any object. Once it is removed then further use of it raise NameError.
my_set={'a','b','c','d','e'}
del my_set
print(my_set)
Here we will removed the set object by using del, so the last line will generate the error ( NameError)

All set methods Questions with solutions on set discard()
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here





    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer