Trouble with for loop
Boris Borcic
bborcic at gmail.com
Tue Nov 6 13:54:14 CET 2007
Shriphani wrote:
> On Nov 6, 3:09 pm, Ant <ant... at gmail.com> wrote:
>> On Nov 6, 9:59 am, Shriphani <shripha... at gmail.com> wrote:
>> ...
>>
>>> My main intention is to state that each of the variables namely a, b,
>>> c, ## can take value from 1 to 9.
>>> How do I go about this ?
>> It sounds like you are after something like:
>>
>> for var in (a, b, c, d, e, f):
>> assert var in [1, 2, 3, 4, 5, 6, 7, 8, 9]
>>
>> but it's hard to tell without some more information from you on
>> exactly what you are trying to achieve.
>
> I want to obtain a number whose first digit "a" is divisible by 1,
> 10*b +a is divisible by 2, 10^2*c + 10b + a is divisible by 3 and so
> on.
And so on ? up to how many digits ?
10^3 is divisible by 4 and 10^4 is divisible by 5 so that the conditions
on the fourth and fifth digits boil down to 10^2*c+10b+a being divisible
by 4 and 5 in supplement to 3, iow divisible by 60. This implies a==0 but you
seem to say that a must be in [1, 2, 3, 4, 5, 6, 7, 8, 9].
> I hope my question is a bit clearer now.
Not really :)
> Thanks,
> Shriphani Palakodety
>
More information about the Python-list
mailing list