-1
Talk guys, I’m uncrossing python and I’m putting together a simple program that will gradually divide the modules, add treatments etc... The problem is this: in the code below, the program only works once. I create the user and at the end it shows me that the user was created and the key:value and calls the start function, but when I select a new option, the program simply ends. Could someone give me a hint?
# cadastar usuario
# login
# sair do sistema
# mostar tela
# mostar dados do usuario
import sys
bd = {}
def cadastar_usuario (user = 0, pwd = 0):
usuario = input("Por favor, digite um nome de usuário: ")
senha = input("Digite uma senha: ")
bd.update({usuario: senha})
print("Usuario cadastrado com sucesso! \n ", bd, "\n\n")
inicio()
def entrar():
print("Usuario entrou")
def mostrar_dados():
print("Mostrando dados")
def sair():
print("Até a proxima")
# sys.exit()
def inicio():
select = int(input("Escolha uma opcao: \n"
"1 - Cadastrar usuario \n"
"2 - Entrar \n"
"3 - Mostrar dados de usuarios \n"
"4 - Sair do sistema \n"))
return select
opcao = {1:cadastar_usuario, 2:entrar, 3:mostrar_dados, 4:sair}
opcao[inicio()]()
Shouldn’t have a noose to call the function
inicio()
until you type4
to get out?– Tuxpilgrim
Yes, I’m going to implement it, but even without the loop, because I’m following the pathways for it not to end, it should work, right? For example, if I select option 1, then type in a user and password, it displays and calls the start function, because when I choose another option, or even 1 again it ends? Or I’m wrong and that’s just missing the loop?
– Danilo Sampaio