-2
I’m starting to learn python and wanted to create a kind of login, only that the code ends without having chosen to end.
from time import sleep
print('=='*20) print('=='*8,'LOGIN','=='*8) print('=='*19) print() print('TYPE 1 TO EXIT SYSTEM nDIGITE 2 TO CONTINUE') opc=int(input(' 1 or 2 : '))
while True : login = [] password = []
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
The code is too confusing. If you simplify it the problem probably goes away by itself.
– Maniero
Programming, among many other things, will involve you identifying patterns and separating the problem into small parts using logical reasoning. At first it can be confusing, but keep insisting until your code is short, only with the minimum of steps necessary to reach the result. Remove repetitions and use language features to control the flow. Let the machine make the decisions instead of yourself make all possible combinations and write one by one.
– Bacco