mardi 8 juin 2021

Python mistake in if else [duplicate]

a few days ago, I started learning python and now I try to make a text adventure. I can not find the mistake in my code. The code is written in python.

Edit: the output for the 'classes' e.g. Hunter, is always the 'Hunter' class, no matter what the input is.

print('TEXT ADVENTURE\n')

coins = 0
weapon = 'none'
classes = ['Hunter', 'Warrior', 'Mage']
player_class = 'none'

print('Coins = ' + str(coins) + '\nWeapon = ' + weapon + '\nClass = ' + player_class)

print('\nChoose your class: ')
print(classes)
class_selection = input('"H" for Hunter, "W" for Warrior, "M" for Mage: ')

if class_selection == 'H' or 'h':
    print('Hunter')
    player_class = 'Hunter'
elif class_selection == 'W' or 'w':
    print('Warrior')
    player_class = 'Warrior'
elif class_selection == 'M' or 'm':
    print('Mage')
    player_class = 'Mage'
else:
    print('This class does not exist, please check your input!')

Aucun commentaire:

Enregistrer un commentaire