0

How to add something to your "dictionary"

i have dictionary, for the example, myDc = {Apes= 3, Birds=4}, how to add new words to myDc Dictionary with input users function thanks you for your answer

12th Dec 2017, 11:00 PM
Razka Agniatara
Razka Agniatara - avatar
2 Answers
+ 3
I assume the language to which you are referring is Python, since I don't know any other language using the term "dictionary". That being said... Let's say I have a dictionary fruits; fruits = {"Apples":, "Pears":, "Oranges":} But I want the values to be user-inputted values. I could do this: app = int(input("Apples: ")) pea = int(input("Pears: ")) ora = int(input("Oranges: ")) Then fruits would be: fruits = {"Apples":app, "Pears":pea, "Oranges":ora} And then you modify it for your own example. 😉
12th Dec 2017, 11:29 PM
blackcat1111
blackcat1111 - avatar
0
Swift also has dictionaries, but I'm pretty sure the implementations in both Python and Swift are the same.
12th Dec 2017, 11:53 PM
Zeke Williams
Zeke Williams - avatar