I am trying to perform recursion but the code is running twice. How to break recursion loop? I want it to run only once. Can anyone help me out with this?
x = 5
def my_fun():
global x
if x == 5:
print('x is 5')
x = 3
my_fun()
print('x is 3')
my_fun()
Expected Output
- x is 5
- x is 3
Output from code
- x is 5
- x is 3
- x is 3