Python Forum
declaring a new dictionary - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: declaring a new dictionary (/thread-41546.html)



declaring a new dictionary - dedagent0900 - Feb-03-2024

The question: How would we declare a new dictionary named myDict with one key-value pair where the key is "one" with a value of the integer of 1? You can either use single or double quotes, but ensure there are no spaces in your answer.

My solution:
myDict={"one":"1"}
This input is wrong and I am not sure why.


RE: declaring a new dictionary - dedagent0900 - Feb-03-2024

the value is a string not an integer


RE: declaring a new dictionary - rob101 - Feb-03-2024

If you need an integer, use 1:

myDict={
    "one":1}