Menu

Menu

Sunday, 8 April 2018

Python dictionary clear


dictionary.clear() method removes all items from the dictionary.

Example

                                dic={1:"one",2:"two"}
                  print(dic)

                  dic.clear()

                 output: dic ={}

what means any and all in python?

In python any is used for OR operation.If any of the item is true then returns true.

And all represent AND if all of the item is true then returns true.

example:                                           


 >>> any([True,True])
True
>>> any([True,False])
True                          

Example for all operation: 
>> all([True,True])
True
>>> all([True,False])
False
>>> all([False,False])
False