0
enter=input("Enter a char : ")
if enter=='a' or 'A':
    print("a")
elif enter=='b' or 'B':
    print("b")
else:
    print('c')

if I enter any character other than a,A,b,B should print c.But it is printing a, any reason why? I am new to programming so apologises if it is a silly question.

Thanks in advance

Nav
  • 31
  • 3

1 Answers1

1

The condition doesn't do what you think. It should be:

if enter == 'a' or enter == 'A':

Or you can use the in operator and a list:

if enter in ['a','A']:

Do something similar to the other case.

Christian Tapia
  • 33,620
  • 7
  • 56
  • 73