I wrote this script for illustration purposes only, because I'm getting the same "Context Action" suggestion from PyCharm elsewhere in a larger script (script running fine).
dog = "Hungry"
def animal(status):
while True:
if status == "Hungry":
action = "Feed Me"
print(action) # Right here it's highlighting "action" and asking me to add global statement
animal(dog)
Am I not assigning the variable "action" locally within my function "animal()"; and therefore I can freely use it anywhere else within the same function? Can someone explain why it's suggesting to make it a global variable?
Thank you!!!