Python classes implemetation difficulties

Posted: asked May 19 at 11:19 - Source : stackoverflow

Every time that I try to run this code in the python idle it says that my indentation is incorrect, and I have done numerous alterations to try to get it running, none of which worked. Any advice you could give me to get it working?

from random import randint
class enemy:
    def __init__(self, type, bhealth, dmglvl):
        self.type = type
        self.bhealth = int(bhealth)
        self.dmglvl = int(dmglvl)
        enhealth=self.bhealth
    def eninfo(self):
        return '{} {} {}'.format(self.type, self.bhealth, self.dmglvl)
    def battleintro(self):
        return 'an enemy {} has appeared! \nIt has: {} health.'.format(self.type, self.bhealth)
    def hit(self):
        print('You swing your sword at the {}.'.format(self.type))
        chardmg=randint(8,15)
        enhealth-=chardmg
        print('You deal {} damage. The {} has {} hit-points left.'.format(chardmg, self.type, enhealth))
        if enhealth <=1:
            return 'The {} Died!'.format(self.type)
enemy1 = enemy("goblin", 15, 1)
print(enemy1.eninfo())
print(enemy1.battleintro())