Sep-17-2020, 06:48 PM
If you don't know how to solve a problem like this you have a big hole in your understanding of Python variables and scope. You should do some reading because this same problem is going to keep reappearing in ever more devious ways until you understand what is going on. When I was first learning Python I found this useful:
https://www.geeksforgeeks.org/namespaces...in-python/
Variables defined inside a function exist in the function's scope (or namespace). These variables disappear once the function is done running. You cannot define the number of password tries inside your authorization function because each time authorization function is done running, the nb_attempt variable is forgotten (is deleted). You must define the nb_attempt variable somewhere else, in a scope/namespace that is not deleted.
https://www.geeksforgeeks.org/namespaces...in-python/
Variables defined inside a function exist in the function's scope (or namespace). These variables disappear once the function is done running. You cannot define the number of password tries inside your authorization function because each time authorization function is done running, the nb_attempt variable is forgotten (is deleted). You must define the nb_attempt variable somewhere else, in a scope/namespace that is not deleted.