-1

This is my beginner homework for creating urinalysis specimen quality evaluation for urine culture. I want to end the script early if a certain condition is met, but the script is still continuing. How can I end the script early?

print("Welcome to urinalysis specimen quality evaluation for urine culture")
no_epithelial_cell = input("Question 1 : Do epithelial cells in your specimen few or numerous? ")
if no_epithelial_cell == "Numerous" or "numerous" :
    print("Specimen not qualified. Reject specimen ")
if no_epithelial_cell == "Few" or "few" :
    no_bacteria = (input("Question 2 : Do bacterias in your specimen few or numerous? "))
        if no_bacteria == "Numerous" or "numerous" :
            print("Specimen not qualified. Reject specimen ")
        if no_bacteria == "Few" or "few" :
            no_WBC = (input("Question 2 : Does WBC in your specimen positive or negative? "))
                if no_WBC == "Positive" or "positive" :
                    print("Suspect UTI. Proceed urine culture ")
                if no_WBC == "Negative" or "negative" :
                    print("No evidence of UTI ")
Ryan Fu
  • 349
  • 1
  • 5
  • 22

1 Answers1

0

A few things first off, the or keyword is not what you think it does. It works like this: (expr1) or (expr2), expr1 and expr2 being full expressions. That means, your first if no_epithelial_cell == "Numerous" or "numerous": wouldn't work, because it would have to be written like this: if no_epithelial_cell == "Numerous" or no_epithelial_cell == "numerous":, which can be condensed into if no_epithelial_cell.lower() == "numerous":, which will account for all other spellings of the word aswell.

To end a script early, just call exit(0), 0 being the exit code. 0 in this case means that the script has executed successfully. If you want to return from a function instead, use return

0x150
  • 589
  • 2
  • 11