Close
Close

How solve this type of question which is about pattern?

   ranarana7401

        A

      BBB

    CCCCC

  DDDDDDD

EEEEEEEEE


Answers

  •   

    n=int(input("Enter the limit"))
    for i in range(1,n+1):        #to count the lines
        for space in range(1,n-i+1):
            print(" ",end=" ")
        for j in range(1,i+1):
            print(chr(i+64),end=" ")  #used two j statements to print the first and
        for j in range(i-1,0,-1):        #second half of the pattern
            print(chr(i+64),end=" ")
        print("\n")


    • please edit any mistake✌✌
      - yashmittal

Ask Yours
Post Yours
Write your answer