mercredi 5 octobre 2016

While loop not running as expected

Hey just for some background, I'm a novice enthusiast programmer. I've looked for help on my problem but couldn't find anything. I'm making a text-based adventure recreationally and am wondering what I'm doing wrong. If the user entered a number that was not 1, 2, or 3, it should be rerunning the loop correct?

inventory = []
while weapon == "empty":
    weapon = input("Enter what weapon you would like to use:\n\nSword(1)\nStaff(2)\nBow(3)\n\n)
    if weapon == "1":
        inventory.append("Sword")
    elif weapon == "2":
        inventory.append("Staff")
    elif weapon == "3":
        inventory.append("Bow")
    else:
        weapon == "empty"

Aucun commentaire:

Enregistrer un commentaire