I've got a very basic problem with python variable scope. I tried to get fluent in python today and wrote a number guesser function which is called in a while loop. But the problem is, that It can't break the loop in this way. I know, that I can solve it, if I don't use the function and put all the if-else statements in the while "body". But I would like to solve this problem without changing the structure of the code. I tried to solve it with a return statement but I don't get it.
Thanks for your answers.
import random 
b = 53 #random.randint(0,100)
i = 0
def numberus_guesserus ():
  a = float(input("Guess a number between 0 and 100: "))
  if a==b:
    print("gg, correct!")
    i=5
  elif 100>a>b:
    print("Too high")
  elif a>100:
    print("You didn't get the rules ")
  else:
    print("Too low")
while i<5:
  print(i)
  i+=1
  numberus_guesserus ()
  if i==5:
    print("Number is: " + b)
