Menu Close

Alphabet pyramid

Learn how to print half pyramids using “Alphabet”. Write a program using “for” loop. Get the integer value as input and print half pyramid using alphabet as output.

Num=int(input("Enter an integer: "))

char=65
for i in range(Num):
	for j in range(i+1):
		print(chr(char)+" ",end="")#using end, you can print in the same line without any new line character.
	char+=1
	print()

Input:
        Enter an integer: 5
Output:
        A
        B B
        C C C
        D D D D
        E E E E E


Scrshot


More Codes to Fcuk