I want to make COVID-19 questionnaire and I wrote some code. What I want to make is questionnaire which has 5 questions. Answer is only yes:예 and no:아니오. I'm going to say different things through 'yes or no' numbers. So I count 'yes or no' by 'yes = yes+1' , 'no = no+1'.
The problem is after 'while True:'. if x=1 I would ask first question and after answered yes or no, by x=x+1, go to the next question and so on. However, after I run, It just stuck in first question and I have no idea to go next question.
I want to make code like this. https://stackoverrun.com/ko/q/13070335.
Thank you.
questionnare.py
def yes_or_no(question):
global yes
global no
yes = 0
no = 0
reply = str(input(question + ' (예/아니오): '))
if reply == '예':
yes = yes + 1
elif reply == '아니오':
no = no + 1
else:
return yes_or_no("(예/아니오)로만 대답하시오 (예/아니오) ")
x = 1
while True:
if x == 1:
if (yes_or_no('1. 현재 확진 판정을 받고 치료중에 있습니까?')):
x = x + 1
elif x == 2:
if (yes_or_no('2. 현재 발열 또는 호흡기 증상(기침, 호흡곤란 등)이 있습니까?')):
x = x + 1
elif x == 3:
if (yes_or_no('3. 14일 이내에 확진자와 접촉한 적이 있습니까?')):
x = x + 1
elif x == 4:
if (yes_or_no('4. 14일 이내에 해외국가를 방문한 적이 있습니까?')):
x = x + 1
elif x == 5:
if (yes_or_no('5. 14일 이내에 국내 집단 발생 지역 혹은 시설을 방문한 적이 있습니까?')):
x = x + 1
else:
break
if yes == 1 :
print('능동감시 대상자입니다.')
elif yes>no :
print('의심환자입니다.')
else:
print('건강관리에 유의하세요.')