The assignment is:
- Create an empty list called temperatures.
- Allow the user to input a series of temperatures along with a sentinel value.
(do not use a number for a sentinel value) which will stop the user input. - Evaluate the temperature list to determine the largest and smallest temperature.
- Print the largest temperature.
- Print the smallest temperature.
- Print a message that tells the user how many temperatures are in the list.
The issue I am having is that if my list contains [-11, -44, -77]
my program prints -11
as the lowest temperature. But I need it to print -77
.
My code:
# Create a list called temperatures to capture user input
temperatures_list = []
# Create a while loop to capture user input into the temperatures_list<br />
if __name__ == "__main__":<br />
while True:
enter_number = (input("Please enter a temperature (enter stop to end): "))
if enter_number == "stop": break
temperatures_list.append(enter_number)
lowest_temp = min(temperatures_list)
highest_temp = max(temperatures_list)
total_temps = len(temperatures_list)
# Print output of temperatures input by user
print(f"The numbers you input are:", temperatures_list)
print(f"The lowest temperature you input is: ", lowest_temp)
print(f"The highest temperature you input is: ", highest_temp)
print(f"There are a total of {total_temps} temperatures in your list")