[Solved] Develop a function in Python to generate the following pattern

Develop a function in Python to generate the following pattern

1
AB
123
ABCD
12345
ABCDEF
1234567

Solution

n = int(input("Enter the pattern size: "))
for i in range(1, n+1):
    #sauravhathi
    for j in range(1, i+1):
        if i % 2 == 0:
            print(chr(j+64), end="")
        else:
            #sauravhathi
            print(j, end="")
    print("\r")

Output:

[Solved] Develop a function in Python to generate the following pattern

Happy Learning – If you require any further information, feel free to contact me.

Share your love
Saurav Hathi

Saurav Hathi

I'm currently studying Bachelor of Computer Science at Lovely Professional University in Punjab.

📌 Nodejs and Android 😎
📌 Java

Articles: 444

Leave a Reply

Your email address will not be published. Required fields are marked *