Help with assigning "write virtual pins" in python (RPi)

Hi folks

I am absolutely new to the programming world and apologize for my poor knowledge. Currently am learning the basics to program in python as well as getting to know my raspberry pi 4 better day by day. coming to the actual problem:
For a school project I would like to build an automatized and in my eyes rather complex feeding system for salt water aquariums. heart of the system is a raspberry pi 4 while settings and manual control can be done via blynk app. I have managed to connect blynk to the RPi and even to write any virtual pins into python. Unfortunately I am now stuck as I’m not able to use these values in the rest of the script. For example I am reading the value V0 as following:

import blynklib 

BLYNK_AUTH = 'Z0Vc2hxxxxxxxxxxxxxxxxxxy32nHrjLO8nu5' 


# initialize Blynk 
blynk = blynklib.Blynk(BLYNK_AUTH) 

WRITE_EVENT_PRINT_MSG = "[WRITE_VIRTUAL_PIN_EVENT] Pin: V{} Value: '{}'" 

# register handler for virtual pin V0 write event 
@blynk.handle_event('write V0') 
def write_virtual_pin_handler(pin, value): 
    print(WRITE_EVENT_PRINT_MSG.format(pin, value))

########################################################### 
# infinite loop that waits for event 
########################################################### 
while True:
    blynk.run()

Now I wold like to do following two things:

  1. use V0 and its value (as integer) outside the while loop
  2. update the global V0 value everytime I change the value in the app
  3. save the V0 value so that settings aren’t lost when RPi gets disconnected

Hope you can follow my thoughts and even better if someone could point me in the right direction.

Any reply is highly appreciated, thanks!
Pat

@pge002 please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
The characters you’ve used are not triple backticks.
Triple backticks look like this:
```

Pete.