ADRIAN KELLY wrote:
Can anyone help me with the programme below; i hope you can see what i am 
trying to do, if i enter the wrong password the loop goes on forever and if i 
enter the right one nothing is printed...
i am a newbie............all comments welcome
thanks adrian................ print 'hello'
print 'i am your computer'
# set the values
password='route9999'
Enter_Password=raw_input ('please enter your password: ')

This sets the password once, outside the loop.

#password loop
while Enter_Password != password:
    if Enter_Password !=password:
        print 'try again'
    else:
        print 'well done'

This loops forever, but never asks for a password. You need to ask for a password *inside* the loop.


actual_password = 'route9999'
given_password = ''
while given_password != actual_password:
    given_password = raw_input('please enter your password: ')
    if given_password == actual_password:
        print 'well done'
    else:
        print 'try again'


--
Steven

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to