# Accept integer number and store it to a list until user input is 0.
# Display the content of the list and size of the list.
# Display the highest and lowest numbers.
# Accept integer number and store it to a list until user input is 0.
numbers = []
number_gathering = True
while number_gathering is True:
try:
current_number = int(input())
while current_number != 0:
print(current_number)
numbers.append(current_number)
current_number = int(input())
number_gathering = False
# If input is not an integer displays an error and continues execution
except ValueError:
print("ValueError: Value must be an integer!")
else:
# Display the content of the list and size of the list.
print("Content of list:", numbers)
print("Size of list:", len(numbers))
# Display the highest and lowest numbers if the list is not empty
if len(numbers) != 0:
print("Highest number of list:", min(numbers))
print("Lowest number of list:", max(numbers))
else:
print("There are no highest and lowest numbers, because the list is empty")
Comments
Leave a comment