Dec-01-2020, 11:17 PM
You don't handle empty questions correctly. Be careful about using recursion
question_list = [] def get_questions(): question = input("Enter your question: ") if len(question) == 0: print("No Empty Questions.") get_questions() question_list.append(question) return question for _ in range(3): get_questions() print(question_list)
Output:Enter your question: 1
Enter your question:
No Empty Questions.
Enter your question: 2
Enter your question:
No Empty Questions.
Enter your question: 3
['1', '2', '', '3', ''] <-- Two blank questions
Personally I think a blank question is a great way to indicate you are done entering questions, but if you want to keep asking until a question is answered you should use something like this:def get_questions(): while True: question = input("Enter your question: ") if len(question) == 0: print("No Empty Questions.") else: question_list.append(question) return question