Foundations of Python

111 / 134

The statement for i in my_dictionary : print (i) where my_dictionary is a dictionary

Get Hint

Note - Having trouble with the assessment engine? Follow the steps listed here


Answer is not availble for this assesment

Please login to comment

6 Comments

Hi - this prints the tuples in the dictionary not the keys. 

  Upvote    Share

Hi,

Could you please share a screenshot of your code and it's output?

Thanks.

  Upvote    Share

Hi,

What you have created is a dictionary of tuples. Try this:

mydict = {"One":1,"Two":2}
for i in mydict:
    print(i)

Thanks.

 1  Upvote    Share

my apologies @Rajtilak,

I made the mistake in initializing the dictionary correctly. I should've done it as:

mydict = {"one": 1, "two": 2}

 

  Upvote    Share

Hi,

We all learn from our mistakes. This was a learning point for you and for all our other learners who would read this comment.

Thanks.

  Upvote    Share