Untitled
unknown
python
a year ago
585 B
10
Indexable
#taking input from user
userInput = input("Please enter a word: ")
print()
print("Output pattern is")
#determining the length of the word
length = len(userInput)
#printing the first line of stars which is 2 more than total input letters
print("*" * (length +2))
#looping through the length of the input
for i in range(length):
#printing the pattern for each character which is based on their index
print("*" * (length -i) + userInput[length - i - 1] + " " * (i) + "*")
#finally printing the ending line of stars like the firs one
print('*' * (length +2))
Editor is loading...
Leave a Comment