ERROR: My code hangs without any errors

-1

I'm starting to learn python and wanted to create a sort of login, only the code ends without having chosen to finish.

from time import sleep

print('=='*20) print('=='*8,'LOGIN','=='*8) print('=='*19) print() print('DIGITE 1 PARA SAIR DO SISTEMA\nDIGITE 2 PARA CONTINUAR ') opc=int(input(' 1 ou 2 : '))

while True : login = [] senha = []

if opc == 1: print() print('FINALIZANDO') print() sleep(3) break if opc == 2 : print('PROCESSANDO') print() sleep(4) print('DIGITE 1 PARA CADASTRO\nDIGITE 2 PARA LOGIN') opc2 = int(input('1 OU 2 : ')) if opc2 == 1: print() print('=='*5,'PROCESSO DE CADASTRAMENTO','=='*5) print() login_1 = input('LOGIN : ') login=login+[login_1] sleep(2) print('SALVO') senha_2 = input('SENHA : ') senha=senha+[senha_2] sleep(2) print('SALVO') print() opc3=input('DESEJA FAZER O LOGIN DIGITE 1 OU 2 PARA SAIR : ') #ERRO APÓS ESCOLHER if opc3 == 2: print() print('FINALIZANDO') sleep(2) break if opc3 == 1: print() print('==' * 5, 'LOGIN', '==' * 5) print() login_1 = input('LOGIN :') if login_1 in login: print() senha_1 = input('SENHA :') if senha_1 in senha: print() print('PROCESSANDO') sleep(3) print('LOGIN EFETUADO') break else: print('SENHA INCORRETA') print() print('DIGITE NOVAMENTE A SENHA') print() if senha_1 in senha: print() print('PROCESSANDO') sleep(3) print('LOGIN EFETUADO') break else: break else: print('VOCÊ NÃO TEM CADASTRO') break else: break else: break if opc2 == 2: print() print('=='*5,'LOGIN','=='*5) print() login_1 = input('LOGIN :') if login_1 in login: print() senha_1 = input('SENHA :') if senha_1 in senha: print() print('PROCESSANDO') sleep(3) print('LOGIN EFETUADO') break else: print('SENHA INCORRETA') print() print('DIGITE NOVAMENTE A SENHA') print() if senha_1 in senha: print() print('PROCESSANDO') sleep(3) print('LOGIN EFETUADO') break else: print('VOCÊ NÃO TEM CADASTRO') break else: break else: break

    
asked by anonymous 24.11.2018 / 09:50

2 answers

1

If you have posted your code here exactly the way you did then the error is in the first true while backtracking you did. It will be infinitely rotating the following two lines that define the login and password variables. Correct the indentation / indentation of your program and be happy.

    
24.11.2018 / 19:29
0

As Bacco said, it is interesting to separate the problems into small portions and solve these small portions one by one.

Your code has some problems related to synthase and logic. So let's go for parts. Below I will leave a code that captures an entry and prints it.

Notice that the part that captures an entry is in a function, so you can separate the responsibilities of each piece of code, and make things clearer:

# funcao para coleta de dados
def coleta_entrada():
    entrada = input("digite alguma coisa: \n")
    return entrada


while True:  # loop infinitio para executar sua rotina
    retorno = coleta_entrada()
    print('voce digitou: {} \n'.format(retorno))

I think this is a start for what you want to do ...

    
24.11.2018 / 17:57