Jul-15-2018, 12:06 PM
how to tidy up the playeranswer part with list or other methods?
import random question = list() question1 = input ("Question 1") question.append(question1) question2 = input ("Question 2") question.append(question2) question3 = input ("Question 3") question.append(question3) question4 = input ("Question 4") question.append(question4) answer = list() answer1 = input ("Answer of question 1") answer.append(answer1) answer2 = input ("Answer of question 2") answer.append(answer2) answer3 = input ("Answer of question 3") answer.append(answer3) answer4 = input ("Answer of question 4") answer.append(answer4) random = random.randint(1,4) if random == 1: playeranswer1 = input (question[1]) if playeranswer1 == answer[1]: print("You are right!") else: print("You are wrong...") if random == 2: playeranswer2 = input (question[2]) if playeranswer2 == answer[2]: print("You are right!") else: print("You are wrong...") if random == 3: playeranswer3 = input (question[3]) if playeranswer3 == answer[3]: print("You are right!") else: print("You are wrong...") if random == 4: playeranswer4 = input (question[4]) if playeranswer4 == answer[4]: print("You are right!") else: print("You are wrong...")