mercredi 27 mai 2020

Conditional structure — 'if' and 'elif' — doesn't show the correct result [duplicate]

the program should show me the right result. For example, if cor equals 'vermelho', print ('sua paleta equivale ao por do sol'), but isn't working.

class Bola:

    def escolha(self, cor):
        self.cor = cor

    def paleta(self):
        if self.cor == 'vermelho' or 'laranja' or 'lilas' or 'amarelo':
            print('sua paleta equivale ao por do sol')
        elif self.cor == 'azul' or 'branco':
             print('sua paleta equivale ao ceu')
        else:
             print('paleta nao definida')

bola = Bola()
bola.escolha('azul')
bola.paleta()

Aucun commentaire:

Enregistrer un commentaire