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
int word = ''
for c in input():
word = word + c;
print(word)
Comments
Leave a comment