What function returns is not a list, it is a tuple (think of it as an immutable list).
Your variable aluni
, may cease to exist, on that piece of code is serving no purpose.
As for your doubt, why don’t you do it like this:
def registro():
matricula = input("Número de Matrícula: ")
telefone = input("Número de Telefone: ")
endereco = input("Endereço: ")
return (matricula,telefone,endereco)
dados = registro() # dentro de dados tens todos os dados que foram introduzidos
print(dados[2])
Or you can even unpack the tuple that returns to stay with the variables separately:
...
matricula, tele, endereco = registro()
print(endereco)
If you are going to use only Indice 2 and delete the others you can do it soon:
def registro():
matricula = input("Número de Matrícula: ")
telefone = input("Número de Telefone: ")
endereco = input("Endereço: ")
return (matricula,telefone,endereco)
endereco = registro()[2]
print(endereco)
Remember that inputs always return strings, to convert them you can:
...
int(input("Endereço: "))
...
I couldn’t assign data to the record (). ?
– Kenneth Anderson
@Kennethanderson how so assign the data? I will put in full
– Miguel
I said it wrong, I’m sorry, I’m new to Python. I was saying that I was not managing to make "record()" could not be assigned to "data". I got it now thanks to you, thanks! P.S: Sorry for the explanation/thanks comment.
– Kenneth Anderson
No problem nenum @Kennethanderson, I’m glad I helped
– Miguel