[Tutor] 2 Different Development Invirments, IDLE & PythonWin 2 different results

Bob Gailer bgailer@alum.rpi.edu
Wed Apr 2 16:47:01 2003


--=======19C6751F=======
Content-Type: text/plain; x-avg-checked=avg-ok-2ABE61DC; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 8bit

At 01:21 PM 4/2/2003 -0700, Danny wrote:

>Hi Everyone,
>     My question is I have downloaded IDLE and PythonWIn I have made this 
> very simple program
>
>password = 'foobar'
>count = 0
>while password != 'Unicorn':
>     password = raw_input('password')
>     if count < 3:
>         count = count + 1
>         print count
>     elif count == 3:
>         print 'man thats a hard one'
>print 'welcome in'
>When I run this with IDLE, it works fine and exits after 3 tries. But when 
>you run the same program in PythonWin, it wont exit until you get the 
>password correctly why is this? Or what could I do in PythonWin to make it 
>exit after 3 tries? Thanks for everyone help ahead of time.

I agree with Reggie's comments. It should run forever until you enter the 
correct password.

Suggested code simplification (2 lines shorter and easier to read):

password = 'foobar'
for i in range(3):
     password = raw_input('password')
    if password == 'Unicorn':
         print 'welcome in'
         break
else:
     print 'man thats a hard one'

Bob Gailer
PLEASE NOTE NEW EMAIL ADDRESS bgailer@alum.rpi.edu
303 442 2625

--=======19C6751F=======
Content-Type: text/plain; charset=us-ascii; x-avg=cert; x-avg-checked=avg-ok-2ABE61DC
Content-Disposition: inline


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.463 / Virus Database: 262 - Release Date: 3/17/2003

--=======19C6751F=======--