Replit console is not loading new code

Problem description:
I am making a program, and it has not been working. I had been lead to believe that the console is not loading my code correctly because a variable is showing a value that I used to have it set as. It now has a different value and is still loading the old value.

Expected behavior:
The variables value should be changes inside a if-statement that’s nested inside a while loop, and change throughout the rest of the program.

Actual behavior:
It stays at an old value that is not set in the location I want it to be set. Once the variable should be changed, it displays “None”, but doesn’t even have a value of None.

Steps to reproduce:
Run the repl and you will be prompted to answer a question, you can skip it by pressing enter. The next question you want to enter “hiragana”, it does not matter if the first letter is capitalized, as long as it’s spelled correctly. The question after that, you want to enter a plus sign (+). It will say “Please enter ND”. If you enter ND and press the enter key after that, it will say “Please enter None”. There will be no correct answer to this question. You can view the code and see if I did something wrong, but there was also something I reported about the editor too.

Bug appears at this link:

This is the project. You can read the code and I’m sorry if it’s messy.
Device (Android, iOS, NA leave blank):
Desktop app version (Avatar menu->“Version”) or NA:
Plan (Free, Hacker, Pro Plan):

Hi @randomcat962 !
It appears that your repl is private or deleted.
EDIT: Link to repl:

I have not published it yet, does that affect anything?

No, but you gave the wrong link in the topic post (type not typing)

I think there was fault in my code. Sorry. I was creating a function to change a variable the variable was originated from outside of the function. I changed it to be a function using the return command, and adapted my code to that, it seemed to fix the issue. Still not sure why the code behaved the way it did though.

What lines of code is it?

Pretty sure it was the function on line 93.
I’m currently going through and changing the indentation settings though. From tabs to spaces.

In python, you cannot set variables in enclosing scopes by default.

def enclose():
  x = 2
  def nested():
    x = 5  # only local to 'nested'
    print(x)  # prints 5
  print(x)  # prints 2

The nonlocal keyword is one solution (use global for global variables).

def enclose():
  x = 2
  def nested():
    nonlocal x
    x = 5  # changes x of 'enclose'
    print(x)  # prints 5
  print(x)  # prints 5