This repository has been archived on 2024-10-24. You can view files and clone it, but cannot push or open issues or pull requests.
NG_2022_Stanislav_Mykhailenko/Lesson_2/task3.py

18 lines
519 B
Python
Raw Normal View History

2022-10-27 16:05:50 +00:00
# Lesson 2 Task 3: display all numbers from n to 1, then remove the first number and repeat while n > 0
# Author: Stanislav Mykhailenko
# License: Unlicense
try:
number = int(input("Enter a natural number: "))
if number < 1:
raise ValueError("A natural number is required.")
for biggestNumber in range(number, 0, -1):
for currentNumber in range(biggestNumber, 0, -1):
print(currentNumber, end='')
if currentNumber > 1: print(' ', end='')
print('')
except ValueError:
print("Invalid number entered.")