When Using input, it only seems to work with my If commands, but not my elif/else statements. I do not think if this is a syntax or spacing issue. I would appreciate any help in fixing this. I am essentially just making this script to automate a flowchart by typing yes or no. If the user inputs Yes or No, then it will bring them to the following prompt.
import os
import sys
import logging
print ('Hello! Please type the age of the baby in days')
age = int(input())
if age >= 8 and age <= 21:
print('Obtain urinalysis, blood culture, and perform LP. Many obtain inflammatory markers (IMs)')
print('Increased HSV risk? Type Yes or No')
HSV = input()
if HSV == 'Y' or 'yes' or 'Yes' or 'YES':
print('Send HSV studies.')
print('1. Initiate parenteral antimicrobial(s), including acyclovir. 2. Observe in hospital.')
elif HSV == 'N' or 'no' or 'n' or 'No' or 'NO':
print('1. Initiate parenteral antimicrobial(s). 2. Observe in hospital.')
else:
print('Invalid answer')
print('Was the pathogen or source identified? Type Yes or No')
indentify = input()
if indentify == 'Y' or 'yes' or 'y' or 'Yes' or 'YES':
print('Treat infection')
input()
elif indentify == 'N' or 'no' or 'n' or 'No' or 'NO':
print('1. Discontinue antimicrobial(s) and may discharge hospitalized infant if all cultures are negative at 24 to 36 hours and HSV PCR is negative (if sent). 2. Follow for duration of illness.')
input()
else:
print('Invalid answer')
input()
elif age >= 22 and age <= 28:
print('Obtain urinalysis, blood culture, and IMs.')
print('Is the urinalysis positive? Type Yes or No.')
urinalysis = input()
if urinalysis == 'Y' or 'yes' or 'y' or 'Yes' or 'YES':
print('Send bladder catheterization or SPA urine culture.')
print('Are IMs abnormal? Type Yes or No')
ab_ims = input()
if ab_ims == 'Y' or 'yes' or 'y' or 'Yes' or 'YES':
print('Perform LP.')
print('Was CSF obtained? Type Yes or No')
CSF = input()
if CSF == 'Y' or 'yes' or 'y' or 'Yes' or 'YES':
print('CSF pleocytosis or uninterpretable? Type Yes or No')
CSF_pleo = input()
if CSF_pleo == 'Y' or 'yes' or 'y' or 'Yes' or 'YES':
print('1. Administer parenteral antimicrobial(s) and 2. Observe in hospital.')
print('Was the pathogen or source identified? Type Yes or No')
indentify = input()
if indentify == 'Y' or 'yes' or 'y' or 'Yes' or 'YES':
print('Treat infection.')
input()
elif indentify == 'N' or 'no' or 'n' or 'No' or 'NO':
print('1. Discontinue antimicrobial(s) and may discharge hospitalized infant if all cultures are negative at 24 to 36 hours and HSV PCR is negative (if sent). 2. Follow for duration of illness.')
input()
else:
print('Invalid answer.')
elif CSF_pleo == 'N' or 'no' or 'n' or 'No' or 'NO':
print('Will observation be at home? Type Yes or No')
home = input()
if home == 'Y' or 'yes' or 'y' or 'Yes' or 'YES':
print('1. Administer parenteral antimicrobial(s). 2. Observe at home. 3. Reassess in 24 hours.')
if identify == 'Y' or 'yes' or 'y' or 'Yes' or 'YES':
print('Treat Infection')
input()
else:
pass
elif identify == 'N' or 'no' or 'n' or 'No' or 'NO':
print('1. Discontinue antimicrobial(s) and may discharge hospitalized infant if all cultures are negative at 24 to 36 hours and HSV PCR is negative (if sent). 2. Follow for duration of illness.')
input()
else:
print('Invalid answer.')
elif CSF == 'N' or 'no' or 'n' or 'No' or 'NO':
print('1. Administer parenteral antimicrobial(s) and 2. Observe in hospital.')
print('Was the pathogen or source identified? Type Yes or No')
indentify = input()
if identify == 'Y' or 'yes' or 'y' or 'Yes' or 'YES':
print('Treat infection.')
input()
elif identify == 'N' or 'no' or 'n' or 'No' or 'NO':
print('1. Discontinue antimicrobial(s) and may discharge hospitalized infant if all cultures are negative at 24 to 36 hours and HSV PCR is negative (if sent). 2. Follow for duration of illness.')
else:
print('Invalid answer.')
input()
elif ab_ims == 'N' or 'no' or 'n' or 'No' or 'NO':
print('May perform LP.')
LP = input()
print('Was the LP performed? Type Yes or No')
if LP == 'Y' or 'yes' or 'y' or 'Yes' or 'YES':
CSF = input()
print('Was CSF obtained? Type Yes or No')
if CSF == 'Y' or 'yes' or 'y' or 'Yes' or 'YES':
print('CSF pleocytosis or uninterpretable? Type Yes or No')
CSF_pleo = input()
if CSF_pleo == 'Y' or 'yes' or 'y' or 'Yes' or 'YES':
print('1. Administer parenteral antimicrobial(s) and 2. Observe in hospital.')
print('Was the pathogen or source identified? Type Yes or No')
indentify = input()
if identify == 'Y' or 'yes' or 'y' or 'Yes' or 'YES':
print('Treat infection.')
elif identify == 'N' or 'no' or 'n' or 'No' or 'NO':
print('1. Discontinue antimicrobial(s) and may discharge hospitalized infant if all cultures are negative at 24 to 36 hours and HSV PCR is negative (if sent). 2. Follow for duration of illness.')
input()
else:
print('Invalid answer.')
input()
elif CSF == 'N' or 'no' or 'n' or 'No' or 'NO':
print('1. Administer parenteral antimicrobial(s) and 2. Observe in hospital.')
print('Was the pathogen or source identified? Type Yes or No')
indentify = input()
if identify == 'Y' or 'yes' or 'y' or 'Yes' or 'YES':
print('Treat infection.')
elif identify == 'N' or 'no' or 'n' or 'No' or 'NO':
print('1. Discontinue antimicrobial(s) and may discharge hospitalized infant if all cultures are negative at 24 to 36 hours and HSV PCR is negative (if sent). 2. Follow for duration of illness.')
else:
print('Invalid answer')
input()
else:
pass
elif age >= 29 and age <= 60:
print('Obtain urinalysis, blood culture, and IMs.')
print('Were IMs elevated? Type Yes or No')
ab_ims = input()
if ab_ims == 'Y' or 'yes' or 'y' or 'Yes' or 'YES':
print('1. Send bladdder catherization or SPA urine culture if positive urinalysis. 2. May perform LP. 3. If CSF result is positive: a. Addminister parenteral antimicrobial(s) and b. Observe closely in hospital.')
print('4. If CSF result is negative and either urinalysis negative or positive: a. May administer parenteral or oral microbial(s) and b. May observe closely in hospital or at home.')
print('5. If CSF is not available or uninterpretable: a. Administer parenteral antimicrobial(s) and b. May observe closely in hospital or at home.')
elif ab_ims == 'N' or 'no' or 'n' or 'No' or 'NO':
print('Is urinalysis positive?')
urinalysis = input()
if urinalysis == 'Y' or 'yes' or 'y' or 'Yes' or 'YES':
print('1. Send bladder catherization or SPA urine culture. 2. Need not perform LP. 3. Administer oral antimicrobial(s). 4. May observe closely ata home. 5. Follow-up in 12 to 24 hours.')
elif urinalysis == 'N' or 'no' or 'n' or 'No' or 'NO':
print('1. Need not perform LP. 2. Need not administer antimicrobial(s). 3. Observe closely at home. 4. Follow-up within 24-36 hours.')
else:
print('Invalid answer.')
input()
else:
pass
print('Was the pathogen or source identified at 24 to 36 hours? Type Yes or No')
identify = input()
if identify == 'Y' or 'yes' or 'y' or 'Yes' or 'YES':
print('Was the source limited to urine? Type Yes or No')
source = input()
if source == 'Y' or 'yes' or 'y' or 'Yes' or 'YES':
print('1. Complete treatment with oral antimicrobials. 2. Ddischarge hospitalized infants. 3. Manage for duration of illness.')
input()
elif source == 'N' or 'no' or 'n' or 'No' or 'NO':
print('Treat infection.')
input()
else:
print('Invalid answer')
input()
elif identify == 'N' or 'no' or 'n' or 'No' or 'NO':
print('1. Discontinue antimicrobials if administered. 2. Discharge hospitalized infants. 3. Manage for duration of illness.')
input()
else:
print ('Invalid answer')
input()
else:
print ('Invalid answer. Baby must be 8-60 days old.')
input()