I need help for multidimensional loop

DL Neil PythonList at DancesWithMice.info
Sun Jan 26 18:44:30 EST 2020


On 27/01/20 12:08 PM, pyotr filipivich wrote:
> Growth Hacking Formation <admin at formationgrowthhacking.com> on Sun, 26
> Jan 2020 12:36:05 -0800 (PST) typed in comp.lang.python  the
> following:
>> Hi guys,
>>
>> I need your help please to sold a complicate problem.
>>
>> It is difficult for me to find the solution but in fact, I am sure it is just a few lines of code.
>>
>> The problem is about some kind of multidimensional loop with some test IF.
...

>> https://docs.google.com/document/d/1UQ1-PdU00kQnJCaLJDYHveWyEXLX_5MTv56fwvECb1w/edit?usp=sharing
> 	
> 	I realize that if you could explain it well enough for someone
> else to realize what your problem is, you should be able to see the
> solution yourself.
> 
> 	It would be better if you could provide a short "elevator itch" on
> what you're trying to do.
> 
> 	Cause "multidimensional arrays" can get hairy really fast.  I
> mean, try building a sieve of erostothenses using arrays in integers
> [0..maxint] in size.

+1

Unfortunately, (given that this is a Python list) I would suggest that 
(full-fat) SQL already offers solutions to such 'relationship issues'. 
(hah!) I'm not sufficiently familiar with SQL-Lite to know if/how well 
it manages multi-table "joins". So, back to Python...

Are you aware that it is possible to have one for-loop inside another? 
("nested")

In this case, use one for-loop to one of the tables, another loop for 
another table...

Start with (almost) empty loops which print only the key or identifier 
of 'that' particular table. You should then be able to assure yourself 
that every single combination of account and phone is covered.

Thereafter, complicate things by adding if-statements which cause 
appropriate action, or "pass"/do nothing.

Let us know how you get on...
-- 
Regards =dn


More information about the Python-list mailing list