Answer to Question #306782 in Python for ratul

Question #306782

Write a Python program that will ask the user to input a string (containing exactly one word). Then your program should print subsequent substrings of the given string as shown in the examples below.


1
Expert's answer
2022-03-06T14:04:39-0500
def subString(string):
     
    for n in range(1,len(string) + 1):
        for i in range(len(string) - n + 1):
            j = i + n - 1
            for k in range(i,j + 1):
                print(string[k],end="")
            print()
subString('David')
D
a
v
i
d
Da
av
vi
id
Dav
avi
vid
Davi
avid
David

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS