We are required to create a trivia gave that gives the user the term dates and term number of a Canadian Prime Minister and the player is required to enter the correct prime minister. Here is my code:
from random import*
pm=["Macdonald", "Mackenzie", "Macdonald", "Abbott", "Thompson", "Bowell",
"Tupper", "Laurier", "Borden", "Borden", "Meighen", "King", "Meighen", "King",
"Bennett", "King", "St-Laurent", "Diefenbaker", "Pearson", "Clark", "Trudeau",
"Turner","Mulroney", "Campbell", "Chretien", "Martin", "Harper"]
terms=["July 1, 1867 to Nov. 5, 1873", "Nov. 7, 1873 to Oct. 8, 1878",
"Oct. 17, 1878 to June 6, 1891", "June 16, 1891 to Nov. 24, 1892",
"Dec. 5, 1892 to Dec. 12, 1894", "Dec. 21, 1894 to April 27, 1896",
"May 1, 1896 to July 8, 1896", "July 11, 1896 to Oct. 6, 1911",
"Oct. 10, 1911 to Oct. 12, 1917", "Oct. 12, 1917 to July 10, 1920",
"July 10, 1920 to Dec. 29, 1921", "Dec. 29, 1921 to June 28, 1926",
"June 29, 1926 to Sept. 25, 1926", "Sept. 25, 1926 to Aug. 7, 1930",
"Aug. 7, 1930 to Oct. 23, 1935", "Oct. 23, 1935 to Nov. 15, 1948",
"Nov. 15, 1948 to June 21, 1957", "June 21, 1957 to Apr. 22, 1963",
"Apr. 22, 1963 to Apr. 20, 1968", "Apr. 20, 1968 to June 4, 1979",
"June 4, 1979 to March 3, 1980", "March 3, 1980 to June 30, 1984",
"June 30, 1984 to Sept. 17, 1984", "Sept. 17, 1984 to June 25, 1993",
"June 25, 1993 to Nov. 4, 1993", "Nov. 4, 1993 to Dec. 11, 2003",
"Dec. 12, 2003 to Feb. 5, 2006", "Feb. 6, 2006 -"]
termnum=["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"]
score=0
choiceterm=choice(terms)
choicePM=choice(pm)
choicetermnum=choice(termnum)
for i in range(10):
print(choiceterm[i], choicetermnum[i])
ans=input("Which prime minister reigned in this time?:\n")
if ans == choicePM[i]:
print("Great job!")
score+=1
else:
print("Incorrect! The corret answer was", choicePM[i])
Please ignore the fact that there is no final output that gives the user feedback on how they did. Currently, I am trying to use the choice function so that it will output a term date and term number that corresponds with the proper prime minister yet it does not output in the order of the list I created (Ex. "Term 1, July 1, 1867 to Nov. 5, 1873" and so on).
As of right now, this program outputs a single letter from term dates and a number which do not correspond with each other. Also, when the user enters an incorrect answer, the string index is out of range. I have tried many different things so far that have not worked. So my question is how would I get all of the variables to correspond with each other, yet not being in the order that I listed them in the list? If possible, I would also like some help understanding indices and "for i in..." part as I have a general knowledge of when to use it, but do not know exactly what it does. Thank you.