0

I am trying to recieve multiple user input variables ( for. eg: storage size, RAM, battery) etc. and storing it inside slots to check with a database and return a product. I use try/expect block to get valid user input. My problem is that i need to set certain conditions for each slot types(RAM, battery, price etc.) and if it is not met, return an error message and ask them to re-enter the values.

             try:
                battery = int(re.findall(r'[0-9]+',tracker.get_slot('battery'))[0])
             except:
                battery =0

             ram = tracker.get_slot('ram')
             
             try:
                ram = int(re.findall(r'[2-9]+',tracker.get_slot('ram'))[0])
             except:
                ram =0
             
             price = tracker.get_slot('price')
             
             try:
                price = int(re.findall(r'[0-9]+',tracker.get_slot('price'))[0])
             except:
                price =0

To be precise, if the user enters the RAM required as 36GB, the limit is 16GB and i need to return a message to the user that it is out of scope and ask him to re-enter a valid RAM. Similarly for multiple variables that follows like price, battery etc. Any heads up?

pika9121
  • 1
  • 1

0 Answers0