Baby Steps with Our Text Editor May 2, 2011 1 Comment In this
tutorial we’re going to start using the power of the text editor
that I’ve been badgering you about over the last few tutorials.
We are going to go back to the earlier tutorials and resurrect
some of the code there. Create a new document with your text
editor Save the document to a file called trivia.py You need to
be careful that your text editor doesn’t add ‘.txt’ to the end
of the file’s name as some have the habit of doing. copy the
following function into the file (originally found here, with
some comments dropped): def askQuestion(questionList): question
= questionList answers = questionList[1:] numberOfAnswers =
len(answers)-1 # -1 because the first entry in the list is
number 0 correctAnswer = random.randint(0, numberOfAnswers) #
choose an answer at random # then swap it with the correct
answer spam = answers[correctAnswer] answers[correctAnswer] =
answers answers = spam print question for i in
range(len(answers)): print i,'. ',answers[i] a