Question: Make this code work. It has to have three guesses, then calculate the percent of the right and wrong guesses right_answer = 0 # Initialise

Make this code work. It has to have three guesses, then calculate the percent of the right and wrong guesses right_answer = 0  # Initialise variable to store correct answers.

print("What is the capital of Prince Edward Island ?")
for i in range(1, 4):
   answer = input("Guess 1 :")
   answer = input("Guess 2 :")
   answer = input("Guess 3 :")
   if answer == "Charlottetown": # Check if answer is as expected.
       print ("Correct!")
       break
   print("What is the capital of Newfoundland ?")
for i in range(1, 4):  
   answer = input("Guess 1 :")
   answer = input("Guess 2 :")
   answer = input("Guess 3 :")
   if answer == "St. John's": # Check if answer is as expected.
       print("Correct")
       break
print("What is the capital of Nova Scotia  ?")
for i in range(1, 4):  
   answer = input("Guess 1 :")
   if answer == "Halifax": # Check if answer is as expected.
       print("Correct")
   answer = input("Guess 2 :")
   answer = input("Guess 3 :")
   print("Correct!")
   break
print("What is the capital of New Brunswick  ?")
for i in range(1, 4):  
   answer = input("Guess 1 :")
   if answer == "Fredericton": # Check if answer is as expected.
       print("Correct")
   answer = input("Guess 2 :")
   answer = input("Guess 3 :")
   print("Correct!")
   break
print("What is the capital of  Quebec ?")
for i in range(1, 4):  
   answer = input("Guess 1 :")
   if answer == "Quebec City": # Check if answer is as expected.
       print("Correct")
   answer = input("Guess 2 :")
   answer = input("Guess 3 :")
   print("Correct!")
   break
print("What is the capital of Ontario   ?")
for i in range(1, 4):  
   answer = input("Guess 1 :")
   if answer == "Toronto": # Check if answer is as expected.
       print("Correct")
   answer = input("Guess 2 :")
   answer = input("Guess 3 :")
   print("Correct!")
   break
print("What is the capital of Manitoba ?")
for i in range(1, 4):  
   answer = input("Guess 1 :")
   if answer == "Winnipeg": # Check if answer is as expected.
       print("Correct")
   answer = input("Guess 2 :")
   answer = input("Guess 3 :")
   print("Correct!")
   break
print("What is the capital of Saskatchewan  ?")
for i in range(1, 4):  
   answer = input("Guess 1 :")
   if answer == "Regina": # Check if answer is as expected.
       print("Correct")
   answer = input("Guess 2 :")
   answer = input("Guess 3 :")
   print("Correct!")
   break
print("What is the capital of Alberta   ?")
for i in range(1, 4):  
   answer = input("Guess 1 :")
   if answer == "Edmonton": # Check if answer is as expected.
       print("Correct")
   answer = input("Guess 2 :")
   answer = input("Guess 3 :")
   print("Correct!")
   break
print("What is the capital of British Columbia ?")
for i in range(1, 4):  
   answer = input("Guess 1 :")
   if answer == "Victoria": # Check if answer is as expected.
       print("Correct")
   answer = input("Guess 2 :")
   answer = input("Guess 3 :")
   print("Correct!")
   break
print("What is the capital of Northern West territories  ?")
for i in range(1, 4):  
   answer = input("Guess 1 :")
   if answer == "Yellowknife": # Check if answer is as expected.
       print("Correct")
   answer = input("Guess 2 :")
   answer = input("Guess 3 :")
   print("Correct!")
   break
print("What is the capital of Yukon ?")
for i in range(1, 4):  
   answer = input("Guess 1 :")
   if answer == "Whitehorse": # Check if answer is as expected.
       print("Correct")
   answer = input("Guess 2 :")
   answer = input("Guess 3 :")
   print("Correct!")
   break
print("What is the capital of Nunavut  ?")
for i in range(1, 4):  
   answer = input("Guess 1 :")
   if answer == "Iqaluit": # Check if answer is as expected.
       print("Correct")
   answer = input("Guess 2 :")
   answer = input("Guess 3 :")
   print("Correct!")
   break
print("You got", right_answer, "right and made", 10 - right_answer,
     "wrong guesses.")  # Print count of correct and wrong guesses.
print("Your total score is", (right_answer / 10) * 100, "%")  # Print total score.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Solution Heres a corrected version of your code rightanswer 0 Initialize the variable to store corre... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!