The Python variable is always reset using action.py


I boys. I created an action.py file with several classes. What I'm trying to do is want a variable (in this case, the flag called). I want to set them to zero as the default and change them using the function. For some reason, the flag is always reset to 0 when the flag is used in another function.
`

from typing import Any, Text, Dict, List

from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher

# Import the getData module to fetch the data.
from dbConnect import getData
import dbConnect
import mysql.connector
flag = 0

class FindByLocation(Action):
    def name(self) -> Text:
        return "action_find_by_location"

    def run(self, dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict(Text, Any)) -> List(Dict(Text, Any)):

    location = tracker.get_slot("location")
    price= tracker.get_slot("price")
    cuisine = tracker.get_slot("cuisine")
    print(location)
    # write the sql query here.
    query = "SELECT Name FROM Restaurant WHERE Location = '%s'" % location
    query3 = "SELECT COUNT(Name) FROM Restaurant WHERE Location = '%s' LIMIT 5" % location
    query2 = "CREATE VIEW LocationView AS SELECT RestaurantID, Name, PhoneNumber, Rating, PriceRange, Location, Sublocation FROM Restaurant WHERE Sublocation = '%s'"%(location)



    #pass the sql query to the getData method and store the results in `data` variable.
    var_location = getData(query)
    print(var_location)
    if not var_location:
        flag = 1
        var_sublocation = getData(query2)
        dispatcher.utter_message(text="یہ جگہ کس ایریا میں ہے")
    else:
        if cuisine is not None:
            count = getData(query3)
            dispatcher.utter_message(text="Find By Location",json_message=var_location)
            dispatcher.utter_message(text="Results found",json_message=count)
            dispatcher.utter_message(text="آپ کس پرائس میں کھانا پسند کریں گے")
        else:
            count = getData(query3)
            dispatcher.utter_message(text="Find By Location",json_message=var_location)
            dispatcher.utter_message(text="Results found",json_message=count)
            dispatcher.utter_message(text="آپ کس طرح کا کھانا پسند کریں گے؟")



        return()


class FindBySublocation(Action):
    def name(self) -> Text:
        return "action_find_by_sublocation"

def run(self, dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict(Text, Any)) -> List(Dict(Text, Any)):
    flag = 1
    print("FLAG VALUEEEEEE")
    print(flag)
    location = tracker.get_slot("location")
    query = "SELECT Name, Rating FROM LocationView WHERE Location = '%s'" % (location)
    query2 = "SELECT COUNT(Name), Rating FROM LocationView WHERE Location = '%s'" % (location)

    location = getData(query)
    location_count = getData(query2)
    dispatcher.utter_message(text="Sublocation Restaurants Found",json_message=location)
    dispatcher.utter_message(text="Results found",json_message=location_count)
    dispatcher.utter_message(text="آپ کس طرح کا کھانا پسند کریں گے؟")

    return()


class FindByCuisineAndLocation(Action):
    def name(self) -> Text:
        return "action_find_by_location_and_cuisine"

def run(self, dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict(Text, Any)) -> List(Dict(Text, Any)):

    cuisine = tracker.get_slot("cuisine")
    location = tracker.get_slot("location")
    print(cuisine)
    print(location)
    print("flag value in Cuisine and Location")
    print(flag)
    # write the sql query here.
    if flag==0:
        query = "Select Name, Rating From Restaurant Where Location = '%s' AND RestaurantID IN (SELECT RestaurantID FROM Cuisine WHERE Name = '%s') LIMIT 5" % (location,cuisine)
        query2 = "Select COUNT(Name), Rating From Restaurant Where Location = '%s' AND RestaurantID IN (SELECT RestaurantID FROM Cuisine WHERE Name = '%s') LIMIT 5" % (location,cuisine)
    else:
        query = "Select Name, Rating From LocationView Where Location = '%s' AND RestaurantID IN (SELECT RestaurantID FROM Cuisine WHERE Name = '%s') LIMIT 5" % (location,cuisine)
        query2 = "Select COUNT(Name), Rating From LocationView Where Location = '%s' AND RestaurantID IN (SELECT RestaurantID FROM Cuisine WHERE Name = '%s') LIMIT 5" % (location,cuisine)

    #pass the sql query to the getData method and store the results in `data` variable.
    location_cuisine = getData(query)
    location_cuisine_count= getData(query2)

    print("data: ",location_cuisine)

    dispatcher.utter_message(text="Find By Cuisine And Location ",json_message=location_cuisine)
    dispatcher.utter_message(text="Number of places ",json_message=location_cuisine_count)
    dispatcher.utter_message(text="آپ کس پرائس میں کھانا پسند کریں گے")


    return ()

At the time when my flag, which is to be changed to 1 after execution in sublocation (which is the case according to the terminal), is changed to 0 when used again in another function, in particular find_by_location_and_cuisine

Thank you for your help!