methods in dictionary
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> islam={'to believe':'in all that ordained','prayer':'5 compulsory','fast':'once a year','charity':'2.5percent','pilgrimage':'once in life'}
>>> islam.details()
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
islam.details()
AttributeError: 'dict' object has no attribute 'details'
>>> islam.keys()
dict_keys(['to believe', 'prayer', 'fast', 'charity', 'pilgrimage'])
>>> islam.vales()
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
islam.vales()
AttributeError: 'dict' object has no attribute 'vales'
>>> islam.values()
dict_values(['in all that ordained', '5 compulsory', 'once a year', '2.5percent', 'once in life'])
>>> print(islam.keys())
dict_keys(['to believe', 'prayer', 'fast', 'charity', 'pilgrimage'])
>>> print(islam.values())
dict_values(['in all that ordained', '5 compulsory', 'once a year', '2.5percent', 'once in life'])
>>> type(islam)
<class 'dict'>
>>> islam.copy()
{'to believe': 'in all that ordained', 'prayer': '5 compulsory', 'fast': 'once a year', 'charity': '2.5percent', 'pilgrimage': 'once in life'}
>>> islam2(islam.copy())
Traceback (most recent call last):
File "<pyshell#10>", line 1, in <module>
islam2(islam.copy())
NameError: name 'islam2' is not defined
>>> islam2=islam.copy()
>>> islam2
{'to believe': 'in all that ordained', 'prayer': '5 compulsory', 'fast': 'once a year', 'charity': '2.5percent', 'pilgrimage': 'once in life'}
>>> islam.pop(to believe)
SyntaxError: invalid syntax
>>> islam.pop(to believe)
SyntaxError: invalid syntax
>>> islam.pop('to believe')
'in all that ordained'
>>> islam.remove('to believe)
SyntaxError: EOL while scanning string literal
>>> islam.remove('to believe')
Traceback (most recent call last):
File "<pyshell#17>", line 1, in <module>
islam.remove('to believe')
AttributeError: 'dict' object has no attribute 'remove'
>>>
Comments
Post a Comment