-1

why it always prints the ascending only?

if choose=="A" or "a":
    print("Ascending order: " ,Anewlist)
elif choose=="D" or "d":
    print("Descending order: " ,Dnewlist)
elif choose=="B" or "b":
    print("Ascending order: " ,Anewlist)
    print("Descending order: " ,Dnewlist)
else:
    print("try again")

2 Answers2

2

You need to specify the equality test on the other side of the or command too:

if choose == "A" or choose == "a":
    print("Ascending order: ", Anewlist)

Alternatively, make the choose variable uppercase:

if choose.upper() == "A":
    print("Ascending order: ", Anewlist)
AK47
  • 8,646
  • 6
  • 37
  • 61
1

You should use:

if choose == "A" or choose == "a":

Or:

if choose in ("A", "a"):
Gelineau
  • 1,718
  • 3
  • 17
  • 26