Python redundancy [closed]

The best way to figure it out is to go through it by hand for a few manageable values of N. For instance, if N is 2:

  • i == 0 and 0 < 2 → print "hello", increment i
  • i == 1 and 1 < 2 → print "hello", increment i
  • i == 2 and 2 < 2while-loop condition is no longer satisfied → loop ends

So for N = 2, "hello" is printed 2 times. See the pattern?

Browse More Popular Posts

Leave a Comment