-1
I’m making a program to find the biggest cousin but I’m making the following mistake: builtins.UnboundLocalError: local variable 'Entrada' referenced before assignment
What could it be? The variable Entrada
was defined, I don’t understand....
def Maior_Primo(X):
X = N = Entrada
Primo = 0
RestoPrimo = 0
while Entrada > 0 :
if Entrada == 0:
MP ( 0 )
else:
while N > 0 :
Divisão = Entrada % N
if Divisão == 0:
RestoPrimo = RestoPrimo + 1
N = N - 1
if RestoPrimo == 2 :
if Entrada > Primo:
Primo = Entrada
Entrada = Entrada - 1
return Primo
print(Maior_Primo(2))
In the first line of the function you have defined that X will be equal to N that will be equal to Input. What is the Input value at this point of the code? The variable does not yet exist within the function; by chance it created it outside?
– Woss