From f90daf96cd79bcdc72a8d76b3ab0484f64aad1b3 Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Sun, 15 Jan 2017 14:54:34 +0100 Subject: Sorted out card shuffling, cards are now served in random order and not repeated until all have been served --- flashcards | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'flashcards') diff --git a/flashcards b/flashcards index caf51d8..1cbcfc6 100755 --- a/flashcards +++ b/flashcards @@ -3,7 +3,7 @@ import re import sys from pathlib import Path -from random import randint +from random import shuffle cardRegex = "CARD: " prefixLength = 6 @@ -48,11 +48,12 @@ def extractCards(f): # Loops serving cards to the user until the program is exited def serveCards(cards): while True: - card = cards[randint(0, len(cards) - 1)] - print(card[0]) - input() - print(card[1]) - input() + for card in cards: + print("----------------------------------------------------------------------------") + print(card[0]) + input() + print(card[1]) + input() def debugCards(cardList): for c in cardList: @@ -62,6 +63,7 @@ def debugCards(cardList): def main(): files = getFileList() cards = createCardList(files) + shuffle(cards) serveCards(cards) if __name__ == "__main__": -- cgit v1.2.3