You probably don’t understand how the function works. In this case it executes something and discards any information obtained from it. If you want a value obtained within the function to be delivered where the function is called you must use the command return
. It has two capacities: it closes the execution flow of the function (it is true that without it also closes at the end of the definition of the code of the function, so it is only mandatory to close if it needs to do before the end, conditionally, of course); and also allows something to result, that is, return a value that you will determine right away, and of course if you need to return a return
is mandatory, even to specify what is this value, so only the return
.
def funcao():
return int(input('insira um número:'))
tupla = (funcao(), funcao(), funcao(), funcao())
print(tupla.count(9))
print(tupla)
Behold working in the ideone. And in the repl it.. Also put on the Github for future reference.
Could also have done without the function:
tupla = (int(input('insira um número:')), int(input('insira um número:')), int(input('insira um número:')), int(input('insira um número:')))
Missing return entry:
return int(input('insira um número:'))
– NoobSaibot
https://ideone.com/RUdJUB
– NoobSaibot