mardi 9 octobre 2018

How do I use strings in if else statement in python

I am very new in python .I have a problem I write a code it take a string which is a name of any gate and then it shows table of that gate. And my question is when I write something else for example apple how program says

print(' you didnt write any gate name')

and thats my code I write only starting part

apple=1

while apple==1:

    print ('PLEASE ENTER A GATE TO SEE IT TABLE:')
    gate =input()
    if gate in ['and','AND']:
        print (
        '1. input   2. input   output'  '\n'
            '1              1           1'   '\n'
            '1              0           0'   '\n'
            '0              1           0'   '\n'
            '0              0           0'   '\n'
        )

Also ı have another problem İf a user write 'AnD' instead of 'and' or 'AND', I want its works same how I do it

Aucun commentaire:

Enregistrer un commentaire