So clearly Im doing something wrong. Im a new python/noob coder so it may be obvious for many of you but Im not sure what to do.
class hero():
"""Lets do some heros shit"""
def __init__(self, name="Jimmy", prof="Warrior", weapon="Sword"):
"""Constructor for hero"""
self.name = name
self.prof = prof
self.weapon = weapon
self.herodict = {
"Name": self.name,
"Class": self.prof,
"Weapon": self.weapon
}
self.herotext = {
"Welcome": "Greetings, hero. What is thine name? ",
"AskClass": "A fine name %s. What is your class? " % self.herodict['Name'],
}
def thingy(self, textkey, herokey):
n = raw_input(self.herotext[textkey])
self.herodict[herokey] = n
if self.herodict[herokey] != "":
print self.herodict[herokey]
else:
self.herodict[herokey] = self.name
print self.herodict[herokey]
def setHeroName(self):
self.thingy("Welcome", 'Name')
def setHeroClass(self):
self.thingy("AskClass", 'Class')
So basically you run this and it sets a bunch of default values. It will ask a name, and you give it user input, and it sets the Name key to the new value of your input. They it is suppose to take that new key:value or name:(userinput) and use it in the next little sentence. But instead its going back and using the default value of 'jimmy'.
What do I need to do?