I am doing a class project and for that I am trying to use a function, where it produce conditional output every time depending on the basis of user input. And I want that output to be store in a file automatically every time it produces the result. Am not sure how to do that. Could someone please help me here. below is the code I am working on:
def server_temp(prompt, value_min,value_max):
  while True:
    number_text = input(prompt)
    try:
      number = int(number_text)
    except ValueError:
      print('Invalid number text. Please enter digits.')
      #continue loop and return to the top of the loop
    if number<=value_min:
      print('the room has correct temperature')
      return number
    if number>=value_max:
      print(' the room has very hot temerature ')
      return number
   
#function calling 
server_temp('What is the server room temperature?:',value_min = 21-23,value_max = 24-30)
temp_record= open("room temp record.txt",'w')
temp_record.write('')
temp_record.close()
 
    