Skip to content

Write a Python program to Find Highest and Lowest Value in a Dynamic Dictionary

Class 11th IP (065)

Write a Program to Search for a Key and Update Its Value

SOLUTION..

data = {} # Dynamic dictionary creation n = int(input("Enter number of elements: ")) for i in range(n): key = input(f"Enter key {i+1}: ") value = input(f"Enter value for {key}: ") data[key] = value # Dynamic search and update while True: print("\nCurrent Dictionary:", data) search_key = input("Enter key to search: ") if search_key in data: print("Key found. Value =", data[search_key]) choice = input("Do you want to update the value? (yes/no): ").lower() if choice == "yes": new_value = input("Enter new value: ") data[search_key] = new_value print("Value updated successfully") else: print("Key not found") cont = input("Do you want to search again? (yes/no): ").lower() if cont != "yes": break print("Final Updated Dictionary:", data)