Untitled

mail@pastecode.io avatar
unknown
python
a month ago
585 B
2
Indexable
Never
#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))
Leave a Comment