You really opened my eyes on this one. You introduced a whole lot of new commands and ways of doing things! Though I still don't fully understand the _name_ = _main_ thing, well, as a matter of fact, I don't u nderstand it at all. I just take it cause you said so and I suspect that later I will understand this line. I do though understand most everything else and will be looking to incorperate that into my learning and future programs. There is one thing though.
The def _init_ function...Could you have said "def init" or does it have to be "_init_" and if so...why? Ok, there are two things really. The second one is about encapsulating the test in a "class". What is that all about? Anyway, I hate to seem simple, but I really want to understand this so I can write my calendar and from there, other sites and programs... thanks a bunch as always!
: Here's my first attempt at cleaning up your code. I went ahead and made a class to try to encapsulate the Test functionality as much as possible. I also left the __init__ method ready to read questions from a file. Note that True and False are already defined in Python (make sure you capitalize them properly, though).
:
: I felt that having a test object hold it's own questions and answers made more sense than having global lists or trying to pass lists around so much. And using the append() method of lists will make reading from a file much easier. The lists will grow as long as there are questions to read from the file. A simple loop should do it. Notice how easy it is to print the questions and answers if you keep them in separate lists. My other idea was to use a Dictionary object where the questions are the keys and the answers the values. But that might prove difficult because Dictionaries are not ordered.
:
: I also did the __name__ == '__main__' trick here so that you could import the TestOfKnowledge class into another program if you ever wanted to without having code execute that is only relevant to this particular instance of the test. Let me know if you don't understand something I did.
__________________________________________________________________
sports nutrition
fundraiser ideas