Python Forum
AttributeError: 'list' object has no attribute 'g_s'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AttributeError: 'list' object has no attribute 'g_s'
#1
https://pastebin.com/2L4BChgF
Reply
#2
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, ...?
Reply
#3
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.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#4
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. :)
Reply
#5
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
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#6
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.
Reply
#7
(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
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  AttributeError: 'str' object has no attribute 'size' russoj5 4 7,491 Nov-15-2020, 11:43 PM
Last Post: deanhystad
  Object has no attribute 'replaceall' ? peterp 2 7,203 Nov-10-2020, 09:23 PM
Last Post: buran
  Calling an class attribute via a separate attribute in input wiggles 7 2,892 Apr-04-2020, 10:54 PM
Last Post: wiggles
  ERROR NoneType object has no attribute content denizkb 1 2,635 Nov-21-2019, 01:18 PM
Last Post: denizkb
  AttributeError: 'tuple' object has no attribute 'move' senfik99 2 4,044 Feb-26-2019, 12:42 PM
Last Post: stullis
  text = str(text.encode('utf-8')) AttributeError: 'float' object has no attribute 'enc ulrich48155 2 8,756 Jul-31-2017, 05:21 PM
Last Post: ulrich48155

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020