[Tutor] while Loop

Luke Paireepinart rabidpoobear at gmail.com
Wed Jul 18 21:08:46 CEST 2007

Darren Williams wrote:
> Luke and Kent, you're right, I didn't think JavaScript calculated 
> multiplaction and division before addition and subtraction but seems 
> it does :)
> I dunno what you mean about usedPocketsOne not being defined, didn't I 
> define it with usedPocketsOne = 192000?
no, I said UsedPocketsOne was not defined.  Note the different starting 
Python is case senstitive, meaning usedPocketsOne is not the same as 
So yes, you defined usedPocketsOne with the assignment to 192000, but 
you did not define UsedPocketsOne.

Note what happens when I test your code:
 >>> def main():

     usedPocketsOne = 192000
     junkiesOne = 500
     labSpaceOne = 0
     resultOne = 0
     while usedPocketsOne > (junkiesOne - labSpaceOne) * 17:
         resultOne = resultOne + 1
         usedPocketsOne = (UsedPocketsOne - junkiesOne + labSpaceOne) * 17

 >>> main()

Traceback (most recent call last):
  File "<pyshell#6>", line 1, in -toplevel-
  File "<pyshell#5>", line 10, in main
    usedPocketsOne = (UsedPocketsOne - junkiesOne + labSpaceOne) * 17
NameError: global name 'UsedPocketsOne' is not defined

You should get a similar error, unless you've somehow defined 
UsedPocketsOne somewhere else.

Correction of previous e-mail: This raises a NameError, not a 
SyntaxError, as I said before.  sorry about that.

More information about the Tutor mailing list