-2

this is my code and i need a way to store the input i get from the 'a' variable

print("Hey Welcome To Mental health chatbot")
import time
time.sleep(1)
a = input("So how are you felling today ").strip().upper()
if (a == "NICE") or (a == "GOOD") or (a == "I am good"):
    print("That's nice to hear")
if (a == "BAD") or (a == "NOT NICE") or (a == "IT WAS A BAD DAY"):
    print("Oh")
aarush
  • 1
  • 1

1 Answers1

0

The simplest way is to store the value in a file like that :

def storeVar(a) :
   f = open("filename.txt", "w+") # w+ allow to write and create the file if it doesnt exist
   f.write(a)
   f.close() #always close a file as soon as you stop using it

def readVar() :
   f = open("filename.txt", "r")
   a=f.read()
   f.close()
   return(a)
lou habert
  • 186
  • 1
  • 1
  • 18