-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)
Alan Kavanagh
  • 9,425
  • 7
  • 41
  • 65
1

You should use:

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

Or:

if choose in ("A", "a"):
Gelineau
  • 2,031
  • 4
  • 20
  • 30