[Techtalk] Python question

BUNTER MATTHEW Matthew.Bunter at renaultvi.com
Mon Apr 22 18:02:00 EST 2002


--- Reçu de       VITEUR.BUNTERMA 04 72 96 57 77             22/04/02 18.02

Very F*****g clever!!!

Now I know why I'm part of this list.

THANKYOU.

You have two conditions, make sure that both are met or exceeded if you are
using a while with an if condition. Very good, very very good. I can
understand THIS!!!!

Matt

------------------------------------------------------------------------------

Date: Mon, 22 Apr 2002 09:00:24 -0700
Subject: Re: [Techtalk] Python question


>It prints "Welcome in" endlessly, which is the same as one of my
>solutions. I tried putting in a break or return after the print "Welcome
>in." but Python didn't like it.


I've never done any programming in Python before, either.. but here's an idea:

It's going to print "Welcome in" as long as the password was typed in
correctly and count is less than 3. You don't want to make count equal to
3, because then it will print that it failed as well! But what would happen
if you set count to, say, 4 after  printing "Welcome in"? That would break
the while loop and, at the same time, would keep it from printing "Failed
three times."

So.. I guess the program would look something like this (my syntax might be
wrong, though):

#!/usr/bin/python
password = "foobar"
count = 0
     while (count < 3) :
         if(password!="unicorn") :
             password=raw_input("Password : ")
             count = count + 1
         else :
             print "Welcome in."
             count = 4
     if(count == 3) :
         print "Failed three tries."


--


So.. maybe that's what the problem is? That would be my best guess.. =\
Experimenting with that idea might help you out..


Rosie Nelson - rosie at normalgrrl.com
"I walk alone and sing to myself. I walk
alone in my own personal hell. A place I
call home, it's a place I dwell." --DBS
http://iloveochxc.livejournal.com/
icq 2559739 - aim peaceloveanddoom

---- 22/04/02 18.02 ---- Envoyé à      ---------------------------------------
  -> techtalk(a)linuxchix.org
 CC:
  -> rosie(a)normalgrrl.com



More information about the Techtalk mailing list