mercredi 26 août 2015

keep getting return error in python. I can't find a guide to help me explain why I get the return error in various instances

Only been at this for 2 weeks so bare with me please, I'm also learning from codeacademy. Yes, I did research and cannot find out why it is telling me it is outside of the function

name=input(" input name ")
print("welcome, {}".format (name))

class player():

    def __init__(self, atk, hp,):
        self.atk=atk
        self.hp=hp

    def __str__(self):
        return "{}, {}".format (self.atk, self.hp)

input("Time for a questionnaire to define your stats")
input("press enter to continue....")
print("in an intense battle when both you and your enemy are on the edge of consciousness and you have a chance to flee do you finish off the opponent taking a chance on being struck down or do you flee with your life?")
statq1=input("fight or flee")
if statq1 == "fight":
    return 5+self
elif statq1 == "flee":
    return 5+hp

Aucun commentaire:

Enregistrer un commentaire