How to deal with Dictionary Basics in Python?

How to deal with Dictionary Basics in Python?

This recipe helps you deal with Dictionary Basics in Python
In [1]:
## How to deal with Dictionary Basics in Python
def Kickstarter_Example_56():
    print()
    print(format('How to work with Dictionary Basics in Python','*^82'))
    import warnings
    warnings.filterwarnings("ignore")
    # Build a dictionary via brackets
    unef_org = {'name' : 'UNEF',
                'staff' : 32,
                'url' : 'http://unef.org'}
    # View the variable
    print(); print(unef_org)
    #Build a dict via keys
    who_org = {}
    who_org['name'] = 'WHO'
    who_org['staff'] = '10'
    who_org['url'] = 'https://setscholars.com'
    # View the variable
    print(); print(who_org)
    # Build a dictionary via brackets # Nesting in dictionaries
    unitas_org = {'name' : 'UNITAS',
                  'staff' : 32,
                  'url' : ['https://setscholars.com',
                           'https://setscholars.info']}
    # View the variable
    print(); print(unitas_org)
    # Index the nested list
    print(); print(unitas_org['url'])
    print(); print(unitas_org['url'][0])
    print(); print(unitas_org['url'][1])
Kickstarter_Example_56()
*******************How to work with Dictionary Basics in Python*******************

{'name': 'UNEF', 'staff': 32, 'url': 'http://unef.org'}

{'name': 'WHO', 'staff': '10', 'url': 'https://setscholars.com'}

{'name': 'UNITAS', 'staff': 32, 'url': ['https://setscholars.com', 'https://setscholars.info']}

['https://setscholars.com', 'https://setscholars.info']

https://setscholars.com

https://setscholars.info


Stuck at work?
Can't find the recipe you are looking for. Let us know and we will find an expert to create the recipe for you. Click here
Companies using this Recipe
1 developer from KPMG
1 developer from Vodafone
1 developer from Altimetrik
1 developer from LTI
1 developer from YASH Technologies
1 developer from ANAC
1 developer from MudraCircle
1 developer from HvH
1 developer from New Delhi DataPoint