TempList = []
print("Welcome to Sensor Monitor")
print("1- Submit Temperature")
print("2- Temperature Report")
print("0- Exit program")
Decision= input("What would you like to do? ")
if Decision == '2':
n= len(TempList)
x = sum(TempList)
avgtemp = (x/n)
print('Average temperature!', avgtemp)
print('Max temperature:', TempList.max)
print('Minimum temperature:', TempList.min)
if Decision == '0':
print("GoodBye")
if Decision == '1':
Temp= int(input("What is the temperature? "))
if Temp <= -200 or Temp >= 200:
error = print("Temperature is out of range [-200 <= temp <= 200]")
else:
TempList.append(Temp)
print(TempList)
if max(TempList) == Temp or TempList.max < Temp:
print("This is the highest temperature!")
if min(TempList) > Temp:
print("This is the smallest temperature!")
Я пытаюсь получить среднюю температуру из своего списка, но каждый раз, когда я снова запускаю программу, я теряю предыдущее значение. и всегда заканчивается единственным значением в нем, как мне сохранить предыдущее значение при добавлении нового значения?