From 3ba9b12cad3505cf59ad059d78bfe9fa1db4e1d0 Mon Sep 17 00:00:00 2001 From: Abhyuday-Goyal <107510592+Abhyuday-Goyal@users.noreply.github.com> Date: Sat, 6 Aug 2022 01:18:14 +0530 Subject: [PATCH] Update dictionary.py --- CODES.PY/dictionary.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CODES.PY/dictionary.py b/CODES.PY/dictionary.py index 4716af6..8978436 100644 --- a/CODES.PY/dictionary.py +++ b/CODES.PY/dictionary.py @@ -13,3 +13,13 @@ record={"n":"Arjun","age":20,"dep":"Developer"} print(record) print(record["n"]); + +# To input a dictionary +d = {} +n = input("Enter number of key-value pairs/ elements you want in your dictionary") +while n>0: + k = input("enter the key") + v = input("enter the value") + d[k] = v + n = n-1 +print(d[k])