[Tutor] use of assignment expression
Mats Wichmann
mats at wichmann.us
Sun Aug 16 19:47:08 EDT 2020
On 8/16/20 5:44 PM, Mats Wichmann wrote:
> On 8/16/20 4:31 PM, Alan Gauld via Tutor wrote:
>> On 16/08/2020 14:55, Manprit Singh wrote:
>>
>>> # Program to find smallest n digit number divisible by a number x
>>> n = 5
>>> x = 83
>>> if (no := (10**(n-1) % x)) == 0:
>>> print(10**(n-1))
>
> Since no is never used, why do this (was something missing from your
> example)? Plus, no probably isn't getting the value you want: it will be
> True or False.
sigh, I missed a set of parens here, it will work out right. But... cue
Alan's comments on readability, it fooled me!
More information about the Tutor
mailing list