given an integer, write a program that displays the
number as follows
first line all
digits
second line all except first digit
third line all except
first two digits
.....
last line the
last digit
ex)
5 6 7 8
6 7 8
7 8
8
Explanation:
Here is the program which takes n as input from the user and then uses 2 for loops to print the pattern mentioned in the problem.
Code:
n = input("Enter an integer: ")
for i in range(len(n)):
for j in range(i, len(n)):
print(n[j], end=' ')
print()
output:
PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!
PLEASE COMMENT IF YOU NEED ANY HELP!
Get Answers For Free
Most questions answered within 1 hours.