-1
I’m having trouble passing variables n and m from the starting function to the function computador_escolhe_jogada
. The error message itself points:
Typeerror: computer_choice move() Missing 2 required positional Arguments: 'n' and’m'
How can I pass the values? I thank you already.
def computador_escolhe_jogada(n,m):
if n == m+1:
return "você começa"
usuario_escolhe_jogada(n,m)
else:
return "Computador começa!"
while n != 0 :
return ("O Computador tirou" , (m+1))
return ("Agora restam",(m+1)-(n), "no tabuleiro")
usuario_escolhe_jogada(n,m)
def partida():
n = int(input("Quantas peças? "))
m = int(input("Limite de peças por jogada? "))
computador_escolhe_jogada()
John, avoid using more than one return per function. I suggest you search for the function init(): It serves to start common variables for multiple functions in a class.
– Willian Jesus Da Silva
@Willianjesusdasilva The boy problem above is just methods, he is not using classes and function init is only for class initialization, but yes, I agree that the second version of it is not useful at all and if you want to share the output, you can return both in a list or create a Generator function with the use of Yield
– Guilherme França de Oliveira