<jupyter_start><jupyter_text>Python : Dictionary Manupulation   Simple list<jupyter_code>players = {'Sachin' : 10,
          'Dhoni' : 7,
          'Kohli' : 18,
          'Ganguly': 99}
players['Sachin']<jupyter_output><empty_output><jupyter_text>1. The ``keys()``, ``values()``, and ``items()`` Methods<jupyter_code>print(players.keys())
print(players.values())
print(players.items())<jupyter_output>dict_items([('Sachin', 10), ('Dhoni', 7), ('Kohli', 18), ('Ganguly', 99)])<jupyter_text>2. Adding a new key-value pair<jupyter_code>players['rahul'] = 14

print(players)<jupyter_output>{'Sachin': 10, 'Dhoni': 7, 'Kohli': 18, 'Ganguly': 93, 'rahul': 14}<jupyter_text>3. Removing a key-value pair<jupyter_code>del players['Sachin']

print(players)<jupyter_output>{'Dhoni': 7, 'Kohli': 18, 'Ganguly': 93, 'rahul': 14}<jupyter_text>4. Modifying a value<jupyter_code>players['Ganguly'] = 1

print(players)<jupyter_output>{'Dhoni': 7, 'Kohli': 18, 'Ganguly': 1, 'rahul': 14}<jupyter_text>5. Looping with Dictionary<jupyter_code>players = {'Sachin' : 10,
          'Dhoni' : 7,
          'Kohli' : 18,
          'Ganguly': 99}

for key, value in players.items():
    print(key + " wears jersey " + str(value))
for key in players.keys():
    print(key)
for v in players.values():
    print(v)<jupyter_output>10
7
18
99<jupyter_text>6. The ``get()``, ``setdefault()``Methods<jupyter_code>picnicItems = {'apples': 5, 'cups': 2}

print('I am bringing ' + str(picnicItems.get('cup', 0)) + ' cups.' 'I am bringing 2 cups.')
print('I am bringing ' + str(picnicItems.get('eggs', 6)) + ' eggs.' 'I am bringing 0 eggs.')
print(picnicItems)
spam = {'name': 'Pooja', 'age': 5} 

spam.setdefault('color', 'blue') 

spam.setdefault('color', 'white') 

print(spam)<jupyter_output>{'name': 'Pooja', 'age': 5, 'color': 'blue'}<jupyter_text>7. Nesting   A List of Dictionaries<jupyter_code>user1 = {'name':'Sharath', 'height': 174, 'age': 23}
user2 = {'name':'Manoj', 'height': 165, 'age': 24}
user3 = {'name':'Manjunath', 'height': 180, 'age': 25}

all_user = [user1, user2, user3]
for users in all_user:
    
    print(users)<jupyter_output>{'name': 'Sharath', 'height': 174, 'age': 23}
{'name': 'Manoj', 'height': 165, 'age': 24}
{'name': 'Manjunath', 'height': 180, 'age': 25}<jupyter_text>A Dictionary in a  Dictionary<jupyter_code>users = {'einstein': {
         'first': 'albert', 
         'last': 'einstein', 
         'location': 'princeton'},    
         
         'mcurie': {
         'first': 'marie',
         'last': 'curie',
         'location': 'paris'}}

users.items()
for username, user_info in users.items():
    print("\nUsername: " + username.title())
    full_name = user_info['first'] + " " + user_info['last']
    location = user_info['location']
    
    print("\tFull name: " + full_name.title())    
    print("\tLocation: " + location.title())

name = input("Enter your name ")
password = input("<PASSWORD> password ")
age = input("enter age ")

user=[]
user.append(input("enter your name"))
user.append(input("enter your age"))
print (user)
new=input ("change name to")
user[0]=new
print(user)
user.append(input("enter color"))
print(user)
fname=input("enter your first name")
user.insert(0,fname)
print(user)
del user[4:]

print(user)
del user[2]
print(user)
user.append(input("enter color"))
print(user)
user_dict={}
user_dict['color']=user[3]
user_dict['first_name']=user[0]
user_dict['last_name']=user[1]
user_dict['age']=user[2]
print(user_dict)<jupyter_output>{'color': 'white', 'first_name': 'aara', 'last_name': 'nikhat', 'age': 'blue'}
{'fraction_non_alphanumeric': 0.20523648648648649, 'fraction_numerical': 0.03153153153153153, 'mean_word_length': 5.083904109589041, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '101699', 'license': 'MIT', 'n_tokens_mistral': 1488, 'n_tokens_neox': 1370, 'n_words': 288, 'path': '06.1 Python - Dictionary Manipulation.ipynb', 'repo_name': 'demaria11/python-in-a-notebook', 'size': '3547'}