so I'm trying to make a basic game in Python 2.7. In this particular block of code, I'm trying to compare user input to keys within a dictionary, magicSpells, and then add variables as values. However, when I try to run this code, the for loop defaults to the else statement instead of doing as what I intend for it to do. How should I adjust this code?
Thank you.
spellClassMage = raw_input("What type of mage? \t\n - Electric"
"\t\n - Fire \t\n - Water \t\n - Earth \n"
"Enter your choice: ").lower()
for userinput in spellClassMage:
if words in magicSpells:
player[name] = randHealthMage, spellClass, score #if the input is in magicSpells dict, assign name as key and random health, spell class, and score as values
print("Your character's name is " + str(player.keys()) + ". Your health is "
+ str(randHealthMage) + " and you are a(n) " + str(magicSpells[words]) + " Mage.")
if randHealthMage <= 3:
print("You look a little frail..")
elif randHealthMage >= 17:
print("You feel strong enough to lift a car.")
else:
print("That isn't a listed type!")
Aucun commentaire:
Enregistrer un commentaire