Python Forum
AttributeError: 'list' object has no attribute 'g_s' - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: AttributeError: 'list' object has no attribute 'g_s' (/thread-25443.html)



AttributeError: 'list' object has no attribute 'g_s' - NitinL - Mar-30-2020

https://pastebin.com/2L4BChgF


RE: AttributeError: 'list' object has no attribute 'g_s' - ndc85430 - Mar-30-2020

There's a lot of code there and I don't feel like debugging it for you. At the very least, the traceback tells you on which line the problem occurs. Why are you trying to access some attribute on a list? Do you not expect the object to be a list? Work backwards from the problem and figure out why you're getting the list. If you do expect the list there, what are you trying to do? Access that attribute on each of the items, some particular items, ...?


RE: AttributeError: 'list' object has no attribute 'g_s' - buran - Mar-30-2020

As you obviously seek help, at least make the effort to make a proper post, show with full traceback in error tags, articulate a question, etc.


RE: AttributeError: 'list' object has no attribute 'g_s' - NitinL - Mar-30-2020

I am extremely sorry for the rude post. This was my first post and gosh did i click on the post now without proper info. I swear to not repeat this again.
Also here are the modules for the main program posted above.
https://pastebin.com/YZBJN1hw
https://pastebin.com/1anbaRt8
https://pastebin.com/GQ5Cbfp2
Im a novice and learning Python from Udemy courses

The program was working good.
I tried to instantiate people through a list called 'Player'. This is where i got the error AttributeError: 'list' object has no attribute 'g_s'.
Its not only the 'g_s' attribute, the error is same for all the attributes.
BTW this code is based on creating a simple 'Role Playing Game'.
Thanks for the replies.
Any suggestions on me improving(forum posting, coding) is highly welcomed. :)


RE: AttributeError: 'list' object has no attribute 'g_s' - buran - Mar-30-2020

in your while loop (starti ng line 49) you have multiple for loops. you iterate over Player which is list (and probably plural would be better name). you have for player in Player:, however in the loops you work with Player (i.e. list), not player (instance of class Person). So check lines 52, 55, 60, 67, 76, and so on all the way to the end... you get the problem


RE: AttributeError: 'list' object has no attribute 'g_s' - NitinL - Mar-30-2020

Dear buran, thank you for your insight. I followed your advice and made necessary changes and voila !! The code works.

And I'm unable to find the like button in the forum here. The Rep button is visible alright.


RE: AttributeError: 'list' object has no attribute 'g_s' - pyzyx3qwerty - Mar-31-2020

(Mar-30-2020, 08:30 PM)NitinL Wrote: And I'm unable to find the like button in the forum here. The Rep button is visible alright.
The like button is the first option on the down right side Smile