471,305 Members | 1,428 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,305 software developers and data experts.

Embedded For Loop With No Data

Haven't found an answer to my question in the books and other docs I have
available, so I am asking here.

I have three lists of data retrieved from database tables. I want to cycle
through all three lists using nested FOR loops. What is the behavior if
there are no data in the list used in the middle loop?

Example:

for a in types:
for b in subtypes:
for c in details:
do some processing

Not every item in the 'types' list will have an associated 'subtype'. Does
the index ignore that loop and drop to the one nested beneath it?

Rich

Jul 5 '07 #1
1 1091
On Thu, 05 Jul 2007 22:03:59 +0000, rshepard wrote:
Haven't found an answer to my question in the books and other docs I have
available, so I am asking here.

I have three lists of data retrieved from database tables. I want to cycle
through all three lists using nested FOR loops. What is the behavior if
there are no data in the list used in the middle loop?
Why don't you try it and see for yourself?
types = ["Type A", "Type B", "Type C"]
subtypes = []
details = [1, 2, 3]

Example:

for a in types:
for b in subtypes:
for c in details:
do some processing

Not every item in the 'types' list will have an associated 'subtype'. Does
the index ignore that loop and drop to the one nested beneath it?

Be sure to write back and let us know what you discover.
--
Steven.

Jul 5 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

35 posts views Thread by David Mathog | last post: by
30 posts views Thread by =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.