-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathQuestionHandling.py
43 lines (35 loc) · 996 Bytes
/
QuestionHandling.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""
Ask questions to the user and get their responses.
Questions are stored in APNLP_QuestionsToUser.xlsx
"""
import pandas as pd
def get_questions():
"""
Function to get all questions out of the excel
:return: questions in list format
"""
data = pd.read_excel('Data/APNLP_QuestionsToUser.xlsx')
df = pd.DataFrame(data, columns=['Questions'])
lst = df.values.tolist()
questions = []
for q in lst:
q = str(q)[2:-2]
questions.append(q)
return questions
def ask_questions():
"""
Function to ask questions to users
:return: list of answers
"""
answers = []
for q in get_questions():
while True:
try:
answer = input(q)
if " " in answer:
raise ValueError
answers.append(answer)
break
except ValueError:
print("Invalid answer. Please answer in only one word! :)")
return answers