Sunday, 23 January 2022

Write a python program to check if a given key already exists in a dictionary if the key exists replace another key/value pair

 Write a python program to check if a given key already exists in a dictionary if the key exists replace another key/value pair

Slip 3 Q 1

CODE :



Dict={}
n=int(input('enter number of keys :'))
for x in range(0,n):
    key=input('enter the key :')
    if key in Dict:
        print('the given key exists!')
       
        for key in Dict.keys():
            print(key,end=' ')
        print('\n ^ use differnt keys from above list')
        key=input('enter the key :')
    value=input('enter the value :')
    Dict[key]=value
print(Dict)






1 comment:

Write a Java program to display given extension files from a specific directory on server machine.

 DOWNLOAD     SLIP14Q2 /** * STEPS TO RUN CODE * Step 01 compile the code * Step 02 run the code * Step 03 give a file directory locatio...