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
2 odpowiedzi
+ 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. 😉
0
Swift also has dictionaries, but I'm pretty sure the implementations in both Python and Swift are the same.