On Mon, 22 Aug 2005, Kent Johnson wrote:
> > Is there any way more efficient for run a nested loop? > > > > ------ > > for a in list_a: > > for b in list_b: > > if a == b: break Hi Jonas, Depends on what we're trying to do. Is it necessary to have a nested loop here? What kind of problem is this trying to solve? If the question is: "are any elements in list_a shared in list_b?", then yes, we can avoid nested loops altogether. If we're concerned about efficiency, we can take advanatage of dictionaries, or use something like the 'set' data structure. http://www.python.org/doc/lib/module-sets.html _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor