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
Post a Comment