Print a pattern of letters

 for i in range(1, 6):

    for j in range(65, 65 + i):

        print(chr(j), end="")

    print()





This program uses nested for loops to print a pattern of letters. The outer loop iterates from 1 to 5, and the inner loop iterates from the ASCII value of 'A' (65) to the ASCII value of the current letter. The chr function is used to convert the ASCII value to its corresponding character. The end argument is used to print the letters on the same line.


The output of this program will be:



Comments

Popular posts from this blog

Simple Python Program Code for Snake Game

Project 01: Python Code for Music Recommendation with Explanation

Iris Flowers Classification ML Project with Code