Answer to Question #307105 in Python for ratul

Question #307105

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.

=====================================================================

Hints(1): You may use "for loop" for this task.

Hints(2): You may use print() function for printing newlines.

For example:

print(1)

print(2)

Output:

1

2

=====================================================================

We can use print(end = "") to skip printing the additional newline.

For example:

print(1, end ="")

print(2)

Output:(prints the following output right next to the previous one)

12

=====================================================================

Sample Input 1:

BANGLA

Sample Output 1:

B

BA

BAN

BANG

BANGL

BANGLA

.

=====================================================================

Sample Input 2:

DREAM

Sample Output 2:

D

DR

DRE

DREA

DREAM


1
Expert's answer
2022-03-07T07:10:45-0500
int word = ''
for c in input():
  word = word + c;
  print(word)

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