I have a variable called band
with four possible options: broad
, half1
, half2
, and control
.
My code or Python should perform different computations depending on the variable I choose. As a simple demonstration, I simply print text messages in the example below.
Question:
Why does Python execute the if (instead of elif) conditional, even when I use "half2"
for the variable band
? Python seems to ignore the elif condition and acts like the if condition was true.
band = "half2" # broad, half1, half2, control
if band == "broad" or "half1" or "control":
print("broad or half1 or control")
elif band == "half2":
print("half2")