Python Budget App

AttributeError: ‘str’ object has no attribute ‘name’:

During testing I keep getting the error “AttributeError: ‘str’ object has no attribute ‘name’” when calling the transfer function.

It does not seem to register category as a new instance of the class. It is reading it as a string. I am building the code in VS code and then will move it over and adjust when I complete it, if that matters.

Thank you!
**Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.62 Safari/537.36

Challenge: Budget App

Link to the challenge:

Well how are you calling the transfer function? Maybe the error is there.

Here is the input I entered.

image

I also realized in this picture I accidently removed the line in my transfer function where I create an if statement that says if I have enough to complete the transfer. (I will add that on my end)

First, pleae try to post code - not images, in part so I don’t have to write the code…
Anyway, the error is right there:
food.transfer(50, "clothing")
You are passing a string in the second argument NOT the clothing-object :wink:
The correct way would be food.transfer(50, clothing)

Also you gave the clothing object the name “Business”, so you might wanna change that to not get irritated later on.

1 Like

Thank you so much!

Sorry for the pictures of the code. I tried copying the link to my replit but it would not appear. Will have to look into that.

Make sure you use the option above the text-input of the forum to properly format the link. I think the forum tries to turn blank links into a preview, which for replit and others turns up blank → thus it fails to actually create a clickable element.