In this example we will show how to add a specified key-value pair into a dictionary with Python.
Source Code
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
dict1 = {}
key = input("Please input the key to be added: ")
value = input("Please input the valueto be added: ")
dict1.update({key:value})
print("The updated dictionary is: ", dict1)
Output:
Please input the key to be added: age
Please input the valueto be added: sixteen
The updated dictionary is: {'age': 'sixteen'}