Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #49158

Re: Loop Question

Date 2013-06-25 09:40 -0400
From Dave Angel <davea@davea.name>
Subject Re: Loop Question
References <2149a85e-e41b-46bf-a12d-7565789748a9@googlegroups.com> <afc4753e-d7b0-46b1-80d4-0e2fe8440871@googlegroups.com> <9e7940d2e7647db397ab662d33b06128@posteo.de>
Newsgroups comp.lang.python
Message-ID <mailman.3827.1372167656.3114.python-list@python.org> (permalink)

Show all headers | View raw


On 06/24/2013 08:20 AM, Lutz Horn wrote:
> Hi,
>
> Am 24.06.2013 14:12 schrieb christhecomic@gmail.com:
>> username=raw_input("Please enter your username: ")
>> password=raw_input("Please enter your password: ")
>> if username == "john doe" and password == "fopwpo":
>>      print "Login Successful"
>> else:
>>      print "Please try again"
>
> while not username or not password or username != "john doe" or password
> != "fopwpo":
>      print "Please try again"
>      username=raw_input("Please enter your username: ")
>      password=raw_input("Please enter your password: ")
>
> print "Login Successful"
>
>

That requires you to have four raw_input() calls instead of two.  And 
what purpose does adding the two new clauses to the while test serve? 
How is:

while not username or not password or username != "john doe" or password 
!= "fopwpo":

different from:

while username != "john doe" or password != "fopwpo":

(other than taking more time and space, and being harder to read) ?

-- 
DaveA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Loop Question christhecomic@gmail.com - 2013-06-23 16:18 -0700
  Re: Loop Question rurpy@yahoo.com - 2013-06-23 16:49 -0700
    Re: Loop Question christhecomic@gmail.com - 2013-06-23 20:24 -0700
  Re: Loop Question Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-24 00:23 +0000
  Re: Loop Question christhecomic@gmail.com - 2013-06-24 05:12 -0700
    Re: Loop Question rusi <rustompmody@gmail.com> - 2013-06-24 07:03 -0700
    Re: Loop Question Lutz Horn <lutz.horn@posteo.de> - 2013-06-24 14:20 +0200
    Re: Loop Question Dave Angel <davea@davea.name> - 2013-06-25 09:40 -0400
  Re: Loop Question christhecomic@gmail.com - 2013-06-24 11:23 -0700
    Re: Loop Question John Gordon <gordon@panix.com> - 2013-06-24 18:42 +0000
      Re: Loop Question Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2013-06-24 20:53 +0200
        Re: Loop Question John Gordon <gordon@panix.com> - 2013-06-24 19:00 +0000
          Re: Loop Question Dave Angel <davea@davea.name> - 2013-06-24 15:23 -0400

csiph-web