Питон преждевременно отключается.
Вот фрагмент кода проблемы vv
<pre> import time def password(): ans = "no" while ans == 'no' or ans == 'n': a = 0 password = input("Enter a password. \n(Must contain at least 1 number, 1 captial, 5 characters and have no special characters)\n") if password.isalnum() == True: if password != password.lower(): if len(password) > 4: for i in range(len(password)): try: float(password[i]) except: a = a else: a = a + 1 if a > 0: ans = input("Your password is " + password + "\nIs this the password you wanted? Y/N\n") ans = ans.lower() if ans == 'y' or ans == 'yes': f = open("Password.txt", "w") f.write(password) print("Your password is being added to the database.\n") time.sleep(1) print("...\n") time.sleep(1) print("Your password has been set.") time.sleep(2) f.close() else: print("Test failed!") else: print("You need at least 1 number.") time.sleep(2) else: print("You must have at least 5 characters.") else: print("You need at least 1 capital.") time.sleep(2) else: print("That contains a special character.") time.sleep(2) def username(): ans = "no" while ans == "no" or ans == "n": username = input("What do you want your username to be?\n") if username.isalnum() == True: if len(username) > 4: ans = input("Your username is " + username + " is this correct? Y/N\n") ans = ans.lower() if ans == "y" or ans == "yes": f = open("Username.txt", "w") f.write(username) print("Your username is being added to the database.\n") time.sleep(1) print("...\n") time.sleep(1) print("Your username has been set.") time.sleep(2) f.close() password() else: print("Test failed!") else: print("Your username has to have more than 4 characters.") time.sleep(2) else: print("You username cannot have a special character.") time.sleep(2) username()
Поэтому программа выключается, когда вы отвечаете на вопрос "ans".
Что я уже пробовал:
Я пытался искать ответ повсюду. Я скачивал и повторно загружал python, но ничего не получалось.