[Techtalk] Python question

Mandi mandi at linuxchick.org
Mon Apr 22 11:46:59 EST 2002


ah.  i missed that.  thanks.  :)

On Mon, 22 Apr 2002, BUNTER MATTHEW wrote:

> --- Re=E7u de       VITEUR.BUNTERMA 04 72 96 57 77            22/04/02 17=
=2E29
>
> Mandi,
>
> Yeah tried something like this. It works BUT
>
> 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.
>
> Rgs,
>
> Matt
>
> -------------------------------------------------------------------------=
-
>
> Date: Mon, 22 Apr 2002 11:31:46 -0400
> Subject: Re: [Techtalk] Python question
>
> On Mon, 22 Apr 2002, BUNTER MATTHEW wrote:
>
> >
> > #!/usr/bin/python
> > password =3D "foobar"
> >
> > while password!=3D"unicorn":
> >     password=3Draw_input("Password : ")
> > print "Welcome in."
> >
>
> I've never programmed python before, but here's something:
>
> -----
> #!/usr/bin/python
> password =3D "foobar"
> count =3D 0
>
> while (count < 3) :
>     if(password!=3D"unicorn") :
>         password=3Draw_input("Password : ")
>         count =3D count + 1
>     else :
>         print "Welcome in."
>
> if(count =3D=3D 3) :
>     print "Failed three tries."
>
> -----
>
> It's not pretty, but what it's doing is using the variable "count" to
> check for the three tries.  when it matches, you get the "Welcome in."  I=
f
> it never matches and drops out of the while loop, it checks the value of
> "count" and prints the "Failed three tries." message.
>
> Anyway, I hope that gives you something useful to look at.
>
> --mandi
>
> ---- 22/04/02 17.29 ---- Envoy=E9 =E0      ------------------------------=
-----
>  CC:
>   -> TECHTALK(a)linuxchix.org
> _______________________________________________
> Techtalk mailing list
> Techtalk at linuxchix.org
> http://mailman.linuxchix.org/mailman/listinfo/techtalk
>




More information about the Techtalk mailing list