Nov-28-2020, 01:51 AM
I was told it's better to just post the relevant code but here's the full code.
This one will run.
This one will run.
def get_questions(): try: if sum(scores + [score]) > 100: print("Score average is higher than 100") if len(question_list) > 0: question_list.pop(-1) if len(scores) > 0: scores.pop() get_questions() except ValueError: print("Use Numbers.") get_questions() question_list.append(question) scores.append(score) def get_answers(): global answer choice_number = 0 try: choice_number = int(input("Number of answers? ")) if choice_number > 4 or choice_number < 2: print("Please select [2-4]") choice_number = 0 get_answers() except ValueError: print("Please select [2-4]") get_answers() for ans in range(choice_number): answer = input(f"Answer {ans + 1}: ") if len(answer) == 0: print("No empty answers.") get_answers() question_answers.append(answer) answers.append(choice_number) print(f"Number of answers: {answers}") print(question_answers) q_answers.append(answer) question_answers.clear() def get_right_answer(): right_answer = 0 try: right_answer = int(input("Right Answer: ")) except ValueError: print("Value Error!") get_right_answer() if 0 < right_answer <= answers[0]: sure = input("Are you sure? [Y/n]: ") if sure.lower() == "n": get_right_answer() elif sure.lower() == "y": question_right_answer[right_answer] = answer print(f"Questions: {question_list}") print(f"Right Answers: {question_right_answer}") print(f"Total Score: {sum(scores)}") else: print("Please Select [Y/n]") get_right_answer() else: print(f"Please select 1-{answers}") get_right_answer() def main(): get_questions() get_answers() get_right_answer() def finish(): question_num = len(question_list) ask_continue = input("Do you wish to continue? [Y/n]: ") if ask_continue.lower() == "y": answers.pop() main() finish() elif ask_continue.lower() == "n": print("\n\n==============RESULTS==============\n") print("#\t Question\t Answer\t Score") for i in range(question_num): print(f"{i+1}\t {question_list[i]}\t\t {answer}\t\t {scores[i]}") i += 1 else: print("Please select [Y/n]") finish() if __name__ == "__main__": global answer scores = [] question_list = [] q_answers = [] answers = [] question_answers = [] question_right_answer = {} question = input("Enter your question: ") score = int(input("Enter question score: ")) main() finish()