Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Object-Oriented Python (retired) Inheritance Instance Methods

Error !!

I created an object called log and when I used log.hip_point it shows error. what might be the problem? (PS: I am using python 2.7)

class Character:

  hit_point=7
  xp=5

  def get_weapon(self):
    weapon=raw_input('weapon([S]word,[A]xe,[K]nife): ').lower()

    if weapon in 'sak':

      if weapon=='s':
        return 'sword'
      elif weapon=='a':
        return 'axe'
      else :
        return 'knife'

    else:
      return self.getweapon()

  def __init__(self,**kwargs):
    self.name=raw_input('Enter: ' )
    self.weapons=self.get_weapon()
    self.hp=

    for k,v in kwargs.items():
        setattr(self,k,v)
Afrid Mondal
Afrid Mondal
6,255 Points

is it hip_point or hit_point???

1 Answer

andi mitre
STAFF
andi mitre
Treehouse Guest Teacher

Hey Saro - for starters one error that you might be getting is a syntax error on line self.hp =. Can you possibly share all the other errors you are getting?

Cheers