25.3k views
1 vote
Write a program that asks the user to type a number nl and the program prints the number entered five times along with two consecutive numbers. Using nested "for" loops. (Marks: 0.5) Example: If the input is 3 , then the program will print:

33333
44444
55555

User Shahriar
by
7.5k points

1 Answer

5 votes

Final answer:

To write a program that asks the user to type a number and prints the number entered five times along with two consecutive numbers using nested 'for' loops, you can use the given code.

Step-by-step explanation:

To write a program that asks the user to type a number and prints the number entered five times along with two consecutive numbers using nested 'for' loops, you can use the following code:

nl = int(input('Enter a number: '))
for i in range(5):
for j in range(i+1):
print(nl, end='')
for k in range(i):
print(nl+1, end='')
print()
This code takes the input number from the user and then uses two nested 'for' loops to print the number multiple times along with the consecutive numbers. The outer loop controls the number of times the number is printed, and the inner loops handle the printing of the number and the consecutive numbers.
User Sanchit Gupta
by
8.1k points