Please help me with this code

def printPattern(n) :

j, k = 0, 0

# loop to decide the row number  
for i in range(1, n + 1) : 

    # if row number is odd  
    if i % 2 != 0 : 

        # print numbers with 
        # the '*' sign in  
        # increasing order  
        for j in range(k + 1, k + i) : 

            print(str(j) + "*",  
                      end = "") 

        j = k + i 
        print(j) 
        j += 1

        # update value of 'k'  
        k = j 

    # if row number is even 
    else : 

        # update value of 'k'  
        k = k + i - 1

        # print numbers with the  
        # '*' in decreasing order  
        for j in range(k, k - i + 1, -1) : 
            print(str(j) + "*", end = "") 

        j = k - i + 1
        print(j) 

Driver Code

if name == “main” :
n = 5

# function calling  
printPattern(n)

hey @sutirtharoy ,
You haven’t understood the pattern correctly.
You are printing stars between the numbers , although they need to printed after the numbers at the end.
Try again about it and have a look again at the pattern once again.

I hope this helps.