Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tamagochi Selection | Python 3.0 | Begginer

Well, I'm trying to make an initial tamagochi selection (ignore the names, just testing), but I doesn't work.

When I type 2 or 3 or any other name than Rattatouie, I get: "Rattatouie é o seu novo Tamagochi!". In English it would be "Rattatouie is your new Tamagochi!" (I'm brazilian)

def pick_tamagochi():
    print('*'*20,"Tamagochi 2018",20*'*')
    print('1 - Rattatouie')
    print('2 - Rabbitack')
    print('3 - Sonic Hedgehog')
    TamagochiSelect = input('>>> Escolha seu Tamagochi:')

    if TamagochiSelect == '1' or 'Rattatouie':
        TamagochiSelect = 'Rattaouie'
        print('Rattatouie é o seu novo Tamagochi!')
    elif TamagochiSelect == '2' or 'Rabbitack':
        TamagochiSelect = 'Rabbitack'
        print('Rabbitack é o seu novo Tamagochi! ')
    elif TamagochiSelect == '3' or 'Sonic Hedgehog':
        TamagochiSelect = 'Sonic'
        print('Sonic é o seu novo Tamagochi!')
    else: 
        print('Nome não compatível')

print(pick_tamagochi())

Does anyone knows how I can solve it?

like image 859
Matheus Oliveira da Hora Avatar asked Apr 27 '26 13:04

Matheus Oliveira da Hora


1 Answers

You have to use the in operator to test for multiple values:

if TamagochiSelect in ('1', 'Rattatouie'):

Otherwise TamagochiSelect == '1' or 'Rattatouie' simply means to test if TamagochiSelect is equal to '1' or if 'Rattatouie' is True, which 'Rattatouie' always is (because it is a non-empty string).

like image 165
blhsing Avatar answered Apr 29 '26 18:04

blhsing



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!