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

php - Admin SDK -- get information about the group -

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

Python Error - TypeError: input expected at most 1 arguments, got 3 -