summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEduardo Pedroni <e.pedroni91@gmail.com>2017-01-15 14:54:34 +0100
committerEduardo Pedroni <e.pedroni91@gmail.com>2017-01-15 14:54:34 +0100
commitf90daf96cd79bcdc72a8d76b3ab0484f64aad1b3 (patch)
tree1c3cd9ab70da16e3fc51194003f186789bb9544d
parentd31f1337c252a65f3b33e7d74cdbda14547ae39f (diff)
Sorted out card shuffling, cards are now served in random order and not repeated until all have been served
-rwxr-xr-xflashcards14
1 files changed, 8 insertions, 6 deletions
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__":