Write a for loop that prints the Keys of 1 nested dictionary

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Write a for loop that prints the Keys of 1 nested dictionary



1> Create a nested dictionary which contains the subject numbers for the subjects you're doing this year in both the Autumn and Spring semesters. In other words, you should have a dictionary with 2 keys, "Autumn" and "Spring", and the values associated with these keys should themselves be dictionaries where the keys are the subject numbers and the values the names of the subjects.



2> Write a for loop that prints out the numbers of the subjects you did in Autumn.



This is what i have


my_subjects = "Autumn": 37315:"Data", 34567:"Sci", "Spring": 23456:"Eng", 45879:"Math"

for season, season.subjects in my_subjects.items():
print("n Autumn Subject Numbers", season)

for key in season.subjects:
print(key)


AttributeError Traceback (most recent call last)
<ipython-input-208-b1fceae351e6> in <module>()
5
6
----> 7 for season, season.subjects in my_subjects.items():
8 print("n Autumn Subject Numbers", season)
9

AttributeError: 'str' object has no attribute 'subjects'









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard