This blog contain program to accept string from user input. Display string and stripping first character of a string using while loop
First of all, we will create a function called strip(). This function has one argument and the value for the argument is supplied from user input. Statement str = str[1:] will strip first character from a string
def strip(str):
while str:
print(str)
str = str[1:]
Taking user input and supplying it to function
user_input = input('Enter a string: ')
strip(user_input)
Output
Enter a string: Python Python ython thon hon on n
Complete Code
def strip(str):
while str:
print(str)
str = str[1:]
user_input = input('Enter a string: ')
strip(user_input)