Handling AttributeError when accessing properties of a nested object in Python 3.10
I need help solving I'm working with an `AttributeError` when trying to access a property of a nested object..... I have a class structure where `User` has a `Profile`, and `Profile` has an `Address`. Here's a simplified version of my code: ```python class Address: def __init__(self, street, city): self.street = street self.city = city class Profile: def __init__(self, address): self.address = address class User: def __init__(self, profile): self.profile = profile # Creating instances address = Address('123 Main St', 'New York') profile = Profile(address) user = User(profile) ``` Now, when I try to print the user's street like this: ```python print(user.profile.address.street) ``` I receive the following behavior: ``` AttributeError: 'Profile' object has no attribute 'address' ``` I've double-checked that the `Profile` class is correctly initialized with an `Address` instance. I even printed `user.profile` to confirm it's not `None`. I suspect it might have something to do with how the `Address` is being assigned or accessed, but I'm unsure. I've tried debugging by printing out the `user.profile.__dict__`, and it shows an empty dictionary. I don't set `address` directly in `Profile` anywhere after initializing it. Could there be any specific reason why 'address' is not being set correctly? Any insights into what might be going wrong or how to trace this scenario would be greatly appreciated! Any help would be greatly appreciated! I'd be grateful for any help. Has anyone else encountered this?