Python Newbie
Laughlin, Joseph V
Joseph.V.Laughlin at boeing.com
Fri May 21 18:46:25 EDT 2004
> -----Original Message-----
> From: Brian [mailto:blugerz at yahoo.com]
> Sent: Friday, May 21, 2004 3:35 PM
> To: python-list at python.org
> Subject: Python Newbie
>
>
> Hi I am new to this newsgroup and new to programming. I have
> had this interest in learning to program because.......well
> just because. It's just a curiosity that I have. The reason
> I am starting with Python, well some of the websites I went
> to recommended Python, so here I am.
> Ok on to the question.
>
> I am currently using the book "Python programming for
> absolute beginners" by Michael Dawson. The program I am
> working on is a password program....dont laugh I know it's
> really simple to some, but I am kinda stuck. The book shows
> how to code a password program like
> this:
>
> password = raw_input("Enter your password:")
>
> if password == "secret":
> print "Access Granted"
> else:
> print "Access Denied"
>
> raw_input("Press the enter key to exit")
>
> Ok that is easy enough I understand what is going on here.
> As the book goes on it also talks about elif, and while
> loops. At the end of the chapter it gives various challenges
> that the reader is asked to complete. One of the challenges
> is to take the password program from above and change it so
> that the user gets only three attempts to enter the correct
> password. Well I ain't got it to work yet, I thought I came
> close, but no cigar. This is what I have so far: #Limiting
> password atempts to three
>
> password = raw_input("Enter your Password: ")
> count = 0
>
>
> while password != "secret":
> print password = raw-input("Enter your Password: ")
> count += 1
>
The above part will loop until password is equal to "secret".... Control
of the program will not go continue to the below parts of the program
until password == "secret".
Joe
> if password == "secret":
> print "Welcome in."
>
>
> elif count > 3:
> print "Please come back when you remember your Password."
>
> else:
> raw_input("Press enter to exit.")
>
> Ok, I know I may be way off course here but any help would be
> greatly appreciated. I dont want to get frustrated and say
> the heck with it, especially if it is something minor.
> Thanks in advance.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list