[Tutor] How to print something just after 3 attempts?

Brian van den Broek brian.van.den.broek at gmail.com
Tue Jul 17 18:51:00 CEST 2012


On 17 Jul 2012 12:39, "Mark Lawrence" <breamoreboy at yahoo.co.uk> wrote:
>
> On 17/07/2012 16:28, Paul McNally wrote:

<snip enough context to perhaps have lost attributions>

>> I was able to get it working like this...
>>
>> password = "foobar"
>> attempt = 0
>> while (password != "unicorn") and (attempt <= 3):
>
>
> Please we're talking Python here not C so strip out those unneeded
parenthesis.

Not so sure I agree. Python doesn't need them, but I often find code easier
to parse when the scope of binary operators is made clear via parens. The
precedence order of python is just one more thing to recall (and is
fighting for space in my head with precedence orders for a bunch of formal
languages). A bit of extra typing can save a second or cognitive lag each
time the line is read.

Best,

Brian vdB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120717/a7d3773d/attachment.html>


More information about the Tutor mailing list