Respuesta :
Answer:
temperatures = []
i = 0
while i < 5:
try:
t = int(input('Enter a temperature: '))
temperatures.append(t)
i += 1
except ValueError:
print('Enter a number')
print(temperatures)
Explanation:
Hope this helps!
The program illustrates the use of exceptions
Exceptions
Exceptions in programs are used to prevent a program from crashing when it encounters an error or bug
Python Program
The program in Python, where comments are used to explain each line is as follows:
#This initializes the number of valid temperature inputs to 0
count = 0
#This initializes the temperature list
temps = []
#This is repeated until 5 valid inputs are recorded
while count < 5:
#The try block opens here
try:
#This gets the temperature
currentTemp = int(input('Temperature: '))
#This appends the temperature to the list
temps.append(currentTemp)
#This increments the counter by 1
count += 1
#The catch block opens here
except ValueError:
#This prints the exception
print('Temperature must be a number')
#This prints the valid temperatures
print(temps)
Read more about exceptions at:
https://brainly.com/question/18497347