Python Forum
Break for While and For
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Break for While and For
#4
(Oct-16-2018, 11:43 AM)buran Wrote: Not tested but something like
while True: random.randint() #I compute something else here ,but accordingly I might generate new random values if any(self.Itm[k][l]<0 for k in range(self.p.T) for l in range (self.p.N)): print("negative quantity, generate random periods again") else: break
There might be better solution but without seeing rest of the code is difficult to say (i.e. I don't like this double for in the comprehension expression)
Thank you Buran , it worked !!!
Reply


Messages In This Thread
Break for While and For - by juniorcoder - Oct-16-2018, 11:27 AM
RE: Break for While and For - by stullis - Oct-16-2018, 11:39 AM
RE: Break for While and For - by buran - Oct-16-2018, 11:43 AM
RE: Break for While and For - by juniorcoder - Oct-16-2018, 12:54 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020