Monday, 15 February 2010

python - weird issues with an IF loop -


I have a strange omission that with my loop it has the code given below:

 < Code> Diff Run_ Calculator (H, D, M, Y): If M == 01: While True: D = Calculate and Write Android (D, M, Y) if D = 31 31: Calculate and Write HDDIR (H, D, M, Y) D = 01 m = m + 1 y = y if m == 02: whereas true: d = calculate_and_write_hsdir (h, d, m, y) if d = 28 28: calculate_and_write_hsdir (h, d, M, y) d = 01 m = m + 1 if m == 03: is true: print "march" in loop "d = calculation and write / hsdir ( D, M, Y) if D == 31: calculation and write_HSDIR (H, D, M, Y) print "March complete" D = 01m = M + 1  

Basically what I am trying to do is lculate_and_write_hsdir every day, every 24 hours after it (1) i <1 p>

what I'm trying to do, turn it off As soon as it goes by the end of the month, although if I start it on 25th January then it will work properly, where this crash It was broken, but if I start it on February 01, it crashes on February 29

What am I doing wrong?

Here is how I am starting it

  h = 00 # hours d = 28 # day M = 8 # silence y = 2013 # year run_ calculate ( H, d, m, y) run_calculate (000101014) run_calculate (0001010101)  

Try, when your loop will end, because your statement requires you to make sure that when your work is done, you stop executing your existing block. You can also add a break;

  def run_calculate (h, d, m, y): if m == 01: while d & lt; = 31: d = calculate_and_write_hsdir (h, d, m, y) if d == 31: calculation and _late_hsdir (h, d, m, y) d = 01m = m + 1 y = y if m == 02: While D & lt; = 28: d = calculate_and_write_hsdir (h, d, m, y) if d = 28 28: calculate_and_write_hsdir (h, d, m, y) d = 01 m = m + 1 if m == 03: while d & lt; = 31: print "In March Loop" d = Calculation and _writing_HSDIR (H, D, M, Y) if D == 31: calculation and_writing_HSDIR (H, D, M, Y) print "March dan" D = 01 M = M + 1  

No comments:

Post a Comment