Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- def get_cards(filename):
- """
- Return two lists, questions and answers
- read from a file specified by filename.
- """
- #this assumes the question and answer key are in the same file
- cards = []
- answers= []
- with open(filename, mode='r', encoding='utf-8') as card_file:
- for a_card in card_file:
- cards.append(card_file.split()[0])
- answers.append(card_file.split()[1])
- return cards, answers
- cards, answers =get_cards("CARD_FILE_HERE")
- used = []
- score = 0
- stop = False
- while stop == False:
- #get card
- draw = randint(0, len(cards-1))
- used.append(draw)
- print(cards[draw])
- guess = input("What is the answer? ")
- if guess == answers[draw]:
- score += 10
- print("good job your score is now: " + str(score)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement