-1
cad = open('cadastro.txt','w')
aluno = []
laluno = []
print(""" OPÇÔES
1 - cadastrar novo aluno
2 - listar alunos cadastrados
3 - buscar aluno
4 - remover aluno """)
opt = input('Digite uma opção: ')
def cadastrar_aluno():
aluno = str(input("Digite o nome do aluno:"))
aluno=aluno.upper()
def listar_alunos ():
print('Alunos Matriculados', laluno)
if opt == '1':
cadastrar_aluno()
laluno.append(aluno)
elif opt == '2':
listar_alunos()
The variable
aluno
within the functioncadastrar_aluno()
is different fromaluno
out. Change this variable inside the function does not change it out. Try to redo using areturn aluno
in functioncadastrar_aluno()
and then taking the value ofreturn
withaluno = cadastrar_aluno()
.– AlexCiuffa