Я кодирую базу данных, и при этом я застрял в бесконечном цикле.
#!/bin/usr/python3 import os, sys import math
try:
project_file = open('work_good.txt', 'w+')
text = project_file.read()
except FileNotFoundError as error:
text = ('File not found')
print (text)
project_file.close()
with open('work_good.txt', 'r') as f:
my_names = []
my_names = f.readlines()
def Zone():
#Introduction to the database
print ('WELCOME TO THE DATABASE', file=project_file)
print (23*'=', file=project_file)
def Username():
#Ask for users username
usr_name = input ('What do you want your current username to be?: ').strip().capitalize()
print ('Your username is: {}'.format(usr_name), file=project_file)
return usr_name
def Change_Username():
#Information for the user to change their username
change_usr = input ('Would you like to change your username? (y/n): ').strip().lower()
if change_usr == 'y':
status = input ('Enter your new username: ').strip()
print ('Username is changing...', file=project_file)
print ('Your new username is: {}'.format(status), file=project_file)
elif change_usr == 'n':
pass
else:
print ('No such command was given!', file=project_file)
def Password():
set_password = input ('What will be your password?: ').strip()
password = ('Your password is: {}'.format(set_password))
print (password, file=project_file)
def Password_Change():
change_password = input('Do you want to change your password? (y/n): ').strip().lower()
if change_password == 'y':
password1 = input ('What will your new passsword be: ')
password2 = ('Your new password is: {}'.format(password1))
print (password2, file=project_file)
elif change_password == 'n':
print ('Your password remains the same'.upper(), file=project_file)
else:
print ('No such command has been given!', file=project_file)
Zone()
counter = 0
while counter <= 3:
usr_name = []
usr_name = Username()
my_names.append(usr_name)
print (usr_name, file=project_file)
Change_Username() Password() Password_Change()
Я думаю, что в последней строке цикла while это может быть проблема.
Я попытался добавить оператор if и else, но это не удалось.
Я также попытался добавить разрыв, передачу и продолжение, но это также не удалось.
Где могпроблема будет?