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

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -