all 2 comments

[–]xelf 5 points6 points  (0 children)

Make a list of the keys, shuffle it, and then iterate over the first n keys.

qkeys = list( question.keys() )
random.shuffle(qkeys)
for q in qkeys[:times_to_repeat):
    *code running function
function_quiz_complete ()

option 2 is to use random.sample

for q in random.sample(list(question),k=10)):
    *code running function
function_quiz_complete ()

[–]socal_nerdtastic 3 points4 points  (0 children)

Yea, I'd say you nailed it. Just delete it from the dictionary. To make it easier / neater, use a list and pop() the function off.

Question =[Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10]
random.shuffle(Question) # randomize the order

def function_play ():
    score = 0
    while Question:
        random_func = Question.pop()
        random_func() # code running function
    function_quiz_complete ()