[Tutor] How and where to use pass and continue

Sean Perry shaleh at speakeasy.net
Mon Mar 28 05:48:58 CEST 2005


Kevin wrote:
> Ok I have another question now I noticed that at the tope of a while
> loop there will be somthing like this:
> 
> test = None
> while test != "enter":
>          test = raw_input("Type a word: ")
>          if test == "enter":
>               break
> 
> what is the purpose of test = None ?
> 

'test' must be given a value before Python will use it.

Without the first assignment, the program will fail to execute the first 
time it reaches the unknown variable.

Think of it as riming the pump.


More information about the Tutor mailing list