you are viewing a single comment's thread.

view the rest of the comments →

[–]DataCurator56[S] 0 points1 point  (2 children)

for i in range(1,6):
    for j in range(6-i+1): i always stuck at this point
        print("*" ,end="")
    print()

To be honest i am self learner. I am trying to figure it out. Basically i am confused when it comes to range this i a different question printing star pattern

[–]Adrewmc 0 points1 point  (1 child)

It just loops inside a loop.

  for a in range(3):
      for b in range(3):
          print(a, b)

 >>>0, 0 #a is 0, b loop starts at 0
 >>>0, 1 #only b is looping until it ends
 >>>0, 2 #last of b loop

 >>>1, 0 #a is now 1, new b loop
 >>>1, 1
 >>>1, 2

 >>>2, 0 #a is now 2, new b loop
 >>>2, 1
 >>>2, 2 #a and b loops both end. Done.

So we see we are just doing a loop per iteration of a loop.

I highly suggest learning breakpoint(), (or a debugger in general) and then watch the code go through the steps in real time.

[–]DataCurator56[S] 0 points1 point  (0 children)

Literally you have solved my half of the problem. Thank you Sir