-1

I'm new to this and trying to complete a workshop. Keeps giving the "2nd department" as the answer and is frustrating me. It should give the answer as "1st Department" for CP and/or Down.

d1 = ["CP", "Down", "SMA", "Bone Fracture", "Hemiplegia"]
patient =input("What's your complaint? = ")
data = True

for patient in d1:
    if patient == "SMA" or "Bone Fracture" or "Hemiplegia":
        data = False
        break

if data:
    print("1st Department")
else:
    print("2nd Department")   

1 Answers1

2

Change your if condition to:

if patient in ["SMA", "Bone Fracture", "Hemiplegia"]:

You can also probably simplify the code to:

d1 = ["CP", "Down", "SMA", "Bone Fracture", "Hemiplegia"]
patient =input("What's your complaint? = ")
data = patient in d1

if data:
    print("1st Department")
else:
    print("2nd Department")  

zr0gravity7
  • 2,917
  • 1
  • 12
  • 33