grok - Python - Looping over a string -
how loop word user can input example below in python.
enter word: python (user can input word)
p
py
pyt
pyth
pytho
python
(then loops word inputted user)
there may better ways this, simplest:
string = 'python' index in range(1, len(string)): print(string[:index])
Comments
Post a Comment