Python program with letters pyramid

Question:

I need help with python. I have to do this and I don’t know how can I add letters to * pyramid. Thank you first program second program

Asked By: Adrien

||

Answers:

This will help you:

length = 7          # length of the string
word = "Python"     # string to print

# first program
string = '.' * (length - 1) + word
for i in range(length - 1):
    print(string[i:i + length])

# second program
for i in range(1, length):
    _str = word[:i] + '.' * (length - i)
    print(_str[::-1] + _str)

The output is:

......P
.....Py
....Pyt
...Pyth
..Pytho
.Python
......PP......
.....yPPy.....
....tyPPyt....
...htyPPyth...
..ohtyPPytho..
.nohtyPPython.
Answered By: CreepyRaccoon
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.