I have a class called allTheQuestions:
answers = ['def', 'break', 'len(string)']
q1options = ['func', 'def', 'function', 'define'];
q2options = ['break', 'loop out', 'stop', 'abandon'];
q3options = ['string.length', 'str(length)', 'len(string)', 'len.string'];
q1 = raw_input('What is the keyword for functions in Python? ');
q2 = raw_input('What keyword terminates a loop in Python? ');
q3 = raw_input('How do you get the length of a string? ');
questionList = [q1, q2, q3]
questionShuffled = random.shuffle(questionList)
I have a function called questions:
def questions():
score = 0
print(allTheQuestions.questionShuffled)
q1answer = allTheQuestions.q1options[1];
print(q1answer)
I want the function to shuffle my question list and then print them out in a random order. so far I can comment out this line print(allTheQuestions.questionShuffled) and it will run the questions in the order they are in the class. how can I do this so that it will randomize them in different orders?
thanks
Aucun commentaire:
Enregistrer un commentaire