0
Hello, I wish I could instantiate the class Sala
below using as arguments the return of the function choose_sala()
:
The ideal would be to call the class initialization when the function returns Sala
, but I haven’t been successful so far.
Follow the simplified example:
Python 3
class Sala:
def __init__(self, ano, turma):
self.ano = ano
self.turma = turma
print(" Sala Escolhida foi... ")
def say_hello:
print("Hello!")
r1 = [] # desnecessário!
def choose_sala():
r1 = ['8A']
r1 = "".join(r1)
print(r1)
print(r1[0], " ", r1[1]) #para poder usar casa letra separadamente, não deu certo usando a lista normal.
return r1
I wish I could use:
a = Sala(choose_sala())
a.say_hello() # teste da classe
Okay, thanks, it worked great, I knew it was something simple but not as simple as a *. Basic tutorial, here we go!
– George Bueno
@Georgebueno Now that it’s worked out, can I mark my answer as accepted, to close the question? Just click on the green Checkmark next to the answer.
– nosklo