a

SOLUTION.

# Creating a dynamic nested dictionary with user input
student = {
    "name": input("Enter student's name: "),
    "details": {
        "age": int(input("Enter student's age: ")),
        "grade": input("Enter student's grade: "),
        "city": input("Enter student's city: ")
    }
}

# Display the entire dictionary
print("\nStudent Dictionary:", student)

# Accessing nested dictionary values
print("Student's name:", student["name"])
print("Student's age:", student["details"]["age"])
print("Student's grade:", student["details"]["grade"])
print("Student's city:", student["details"]["city"])

    

Leave a Reply

Your email address will not be published. Required fields are marked *

sign up!

We’ll send you the hottest deals straight to your inbox so you’re always in on the best-kept software secrets.