diff --git a/python crush course/chapter-6/dictionary/book's concept/taking_input_for_dict.py b/python crush course/chapter-6/dictionary/book's concept/taking_input_for_dict.py new file mode 100644 index 0000000..730fd7d --- /dev/null +++ b/python crush course/chapter-6/dictionary/book's concept/taking_input_for_dict.py @@ -0,0 +1,11 @@ +#Empty dictionary. +my_dict = {} +#Numbers of items to add. +n = int(input("How many items do you want to add to the dictionary?")) +#Loop to add items to the dictionary. +for i in range(n): + key = input("Enter the key:") + value = input("Enter the value:") + my_dict[key] = value +#Print the final dictionary. + print("Final dictionary is:", my_dict)