Given a string str as the input. The task is to print the pattern as shown in the example.
Input : str = “geeks”
* s k
In the first line print the first character in the string.
In the second line print the next two characters in reverse order.
In the third line there are not enough characters to print so append *s and print the characters in reverse order.
Input: str = “orange”
e g n
- Initialize an empty list and a variable x with value 1.
- Traverse through the input string str and append the characters to the list.
- If the length of the list is equal to the value of x then
- Print the characters in the list in reverse order.
- Increment the value of x by 1.
- Empty the list
- If the length of the last printed characters is not 0 and it is less than the value of x then append x-length(x) *s and print it in reverse order.
g e e * s k
- Program to print a doormat pattern having a string written in the center in Python
- Check if a string follows a^nb^n pattern or not
- Program to print the pattern 'G'
- Program to print the pattern ‘D’
- Count of occurrences of a "1(0+)1" pattern in a string
- Printing string in plus ‘+’ pattern in the matrix
- Program to print Step Pattern
- Program to print the Zigzag pattern
- Python | Reversed Split Strings
- Python Program to print digit pattern
- Program to Print Pyramid Pattern using numbers
- Python Program for KMP Algorithm for Pattern Searching
- Check if string follows order of characters defined by a pattern or not | Set 1
- Python | Get the smallest window in a string containing all characters of given pattern
- Check if string follows order of characters defined by a pattern or not | Set 2
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.