mardi 7 février 2023

If Else statement only returning the else in python

Note: I am a beginner a python, and probably made a beginner mistake I was trying to make a generator where you type in what you want out of a list, and it will generate it for you. I got it to work, except that when I typed in the list item that I wanted, it just returned my Else statement. Here is a section of my code:

import random;
print('Options:');
print('* Goblin');
choice = input('Your Choice:\n')
if choice == ('Goblin', 'goblin', 'GOBLIN'):
    #generate the names
    goblin_names = ('Xoict','Aag','Tiak','Hebrit','Brarvoikx','Glaarm','Kralx','Fubtard','Teesmoz','Streanierd','Brots','Prakx','Creard','Agsoq','Wissysz','Bluk','Cleaz','Ekiats','Gniatmex','Gledurx');
    goblinNameGen = random.choice(goblin_names);
    print("Name: "+ goblinNameGen);
    print('');'
else:
    print("This creature has not been added yet. =(");

When I typed "goblin", it should have returned a name(from the if statement). Instead, it returned the else statement.




Aucun commentaire:

Enregistrer un commentaire