Two more solutions: #ugly: x,y = 0,0 while 2^x*3^y != 12 and x < 10: y = 0 x = x + 1 while 2^x*3^y != 12 and y < 10: y = y + 1
#short: for x,y in CartesianProduct(range(10),range(10)): if 2^x*3^y==12: break -Marshall Hampton On Jul 23, 4:31 am, mac8090 <bonzerpot...@hotmail.com> wrote: > How does one break from a double for loop, or a loop of two variables? > for example: > > for x in range(10): > for y in range(10): > if 2^x*3^y==12: > break > > (x,y) > > I want this to return (2,1) rather than (9,1). This is just a > simplified example, but that is the approximate situation. > > Any ideas? --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---