Write a python function to print the first n lines of the following pattern.

amannarayanm · September 23, 2021 · Python
def pattern(n):
    for i in range(1,n+1):
        for j in reversed(range(i,n+1)):
            print("X",end="")
        print()
    
    
pattern(10)

Comments

Please sign up or log in to contribute to the discussion.