[Tutor] while Loop

Darren Williams D3IBZ at hotmail.com
Wed Jul 18 21:33:11 CEST 2007


Oops, didn't notice the uppercase U, thanks Luke.

----- Original Message ----- 
From: "Luke Paireepinart" <rabidpoobear at gmail.com>
To: "Darren Williams" <D3IBZ at hotmail.com>
Cc: <tutor at python.org>
Sent: Wednesday, July 18, 2007 3:08 PM
Subject: Re: [Tutor] while Loop


> 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 
> letter.
> Python is case senstitive, meaning usedPocketsOne is not the same as 
> UsedPocketsOne.
> 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-
>    main()
>  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.
> HTH,
> -Luke
> 
> 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