Difference between choice one, choice 2 and choice 3?

Question:
Anyone know the difference between choice 1 and choice 2? Why do i need store the test all function in the count variable in order to update the count variable?
(The purpose of the count variable is just to alternate the messages said if the assertion test fails). I also tried choice 3 but i don’t know why that doesn’t work
Repl link:

import turtle

Tu = turtle.Turtle()
Tu.shape("turtle")
screen = turtle.Screen()
screen.setup(1000, 1000)
Tu.speed(10)
Tu.penup()
count = 2


def word_to_number(the_input):
  input_dict = {
    "usain": "1st place",
    "me": "2nd place",
    "qazi": "3rd place",
    "1st place": "Usain",
    "2nd place": "Me",
    "3rd place": "Qazi",
  }
  try:
    return input_dict[the_input]
  except KeyError:
    return "Please enter a name or what place you came in"
  raise RuntimeError(f"something is wrong with the value:{the_input}")


def test_all(incorrect_count):
  Tu.goto(0, 0)
  Tu.clear()
  try:
    assert word_to_number("1st place") == "Usain"
    assert word_to_number("me") == "2nd place"
    assert word_to_number("qazi") == "3rd place"
    assert word_to_number("usain") == "1st place"
    assert word_to_number("3rd place") == "Qazi"
    assert word_to_number("2nd ple") == "Me"
    Tu.color("green")
    Tu.begin_fill()
    Tu.circle(50)
    Tu.end_fill()
    Tu.goto(-100, -50)
    Tu.write("Correct!Good job!", font=("Ariel", 20, "normal"))
    Tu.goto(0, -60)
  except AssertionError:
    Tu.color("red")
    Tu.begin_fill()
    Tu.circle(50)
    Tu.end_fill()
    Tu.goto(-70, -50)
    Tu.write("Incorrect!", font=("Ariel", 20, "normal"))
    Tu.goto(-300, -75)
    Tu.write(
      "Something is wrong with the assertion inputs", font=("Ariel", 20, "normal")
    )
    Tu.goto(-70, -100)
    if incorrect_count % 2 == 0:
      Tu.write("keep Trying!", font=("Ariel", 20, "normal"))
    else:
      Tu.write("Do Not Give up!", font=("Ariel", 20, "normal"))
    Tu.goto(0, -110)
    incorrect_count += 1
    return incorrect_count


# choice 1
while True:
  print("Enter a name or what place you came in")
  print("Choices: Usain, Me, Qazi for names and 1st, 2nd, 3rd for places")
  my_input = input(">").lower().strip()
  output = word_to_number(my_input)
  print(output)
  count = test_all(count)


# choice 2
while True:
  print("Enter a name or what place you came in")
  print("Choices: Usain, Me, Qazi for names and 1st, 2nd, 3rd for places")
  my_input = input(">").lower().strip()
  output = word_to_number(my_input)
  print(output)
  test_all(count)

# choice 3


def test_all():
  incorrect_count = 2
  Tu.goto(0, 0)
  Tu.clear()
  try:
    assert word_to_number("1st place") == "Usain"
    assert word_to_number("me") == "2nd place"
    assert word_to_number("qazi") == "3rd place"
    assert word_to_number("usain") == "1st place"
    assert word_to_number("3rd place") == "Qazi"
    assert word_to_number("2nd ple") == "Me"
    Tu.color("green")
    Tu.begin_fill()
    Tu.circle(50)
    Tu.end_fill()
    Tu.goto(-100, -50)
    Tu.write("Correct!Good job!", font=("Ariel", 20, "normal"))
    Tu.goto(0, -60)
  except AssertionError:
    Tu.color("red")
    Tu.begin_fill()
    Tu.circle(50)
    Tu.end_fill()
    Tu.goto(-70, -50)
    Tu.write("Incorrect!", font=("Ariel", 20, "normal"))
    Tu.goto(-300, -75)
    Tu.write(
      "Something is wrong with the assertion inputs", font=("Ariel", 20, "normal")
    )
    Tu.goto(-70, -100)
    if incorrect_count % 2 == 0:
      Tu.write("keep Trying!", font=("Ariel", 20, "normal"))
    else:
      Tu.write("Do Not Give up!", font=("Ariel", 20, "normal"))
    Tu.goto(0, -110)
    incorrect_count += 1
    return incorrect_count


input()

This seems to be related to variable scope.

Understanding variable scope:
In python, there are namespaces, which are basically collections of variables. Scope is the region for a namespace. Scopes are nested, there are inner scopes and outer scopes.

The most inner scope has local variables. Local variables are variables defined in a function, and they are only accessible to that function. Since setting variables inside of a function only sets local variables by default, global (module scope) variables cannot be changed from inside a function without some extra code. Also, local variables are erased once a function returns, so the previous values of local variables will not be accessible in the next call to that function.

So, Choice 1 updates the global count variable correctly, and Choice 2 never really changes count.
Choice 3 doesn’t work because local variables do not persist.

what is this about???

@hc306265 This is a question on why OP’s code doesn’t work, and NuclearPasta0 answers the question. You should read the question OP asked to fully understand what this topic is about.