python如何连续输入print_Python:被要求输入两次并输出重复的print语句

appvault = []

passvault = []

def logged():

print("----------------------------------------------------------------------\n")

print("Hello, welcome to the password vault console. ")

modea = input("""Below are the options you can choose from in the password vault console:

##########################################################################\n

1) Find the password for an existing webiste/app

2) Add a new website/app and a new password for it

3) Summary of the password vault

4) Exit

##########################################################################\n

> """).strip()

return modea

def viewapp():

if len(appvault) > 0:

for app in appvault:

print("Here is the website/app you have stored:")

print("- {}\n".format(app))

if len(passvault) > 0 :

for code in passvault:

print("Here is the password you have stored for the website/app: ")

print("- {}\n".format(code))

else:

print("You have no apps or passwords entered yet!")

def addapp():

while True:

validapp = True

while validapp:

new_app = input("Enter the new website/app name: ").strip().lower()

if len(new_app) > 20:

print("Please enter a new website/app name no more than 20 characters: ")

elif len(new_app) < 1:

print("Please enter a valid new website/app name: ")

else:

validapp = False

appvault.append(new_app)

validnewpass = True

while validnewpass:

new_pass = input("Enter a new password to be stored in the passsword vault: ")

if not new_pass.isalnum():

print("Your password for the website/app cannot be null, contain spaces or contain symbols \n")

elif len(new_pass) < 8:

print("Your new password must be at least 8 characters long: ")

elif len(new_pass) > 20:

print("Your new password cannot be over 20 characters long: ")

else:

validnewpass = False

passvault.append(new_pass)

validquit = True

while validquit:

quit = input("\nEnter 'end' to exit or any key to continue to add more website/app names and passwords for them: \n> ")

if quit in ["end", "End", "END"]:

logged()

else:

validquit = False

addapp()

return addapp

def summary():

if len(passvault) > 0:

for passw in passvault:

print("----------------------------------------------------------------------")

print("Here is a summary of the passwords stored in the password vault:\n")

print("The number of passwords stored:", len(passvault))

print("Passwords with the longest characters: ", max(new_pass for (new_pass) in passvault))

print("Passwords with the shortest charactrs: ", min(new_pass for (new_pass) in passvault))

print("----------------------------------------------------------------------")

else:

print("You have no passwords entered yet!")

while True:

chosen_option = logged()

print(chosen_option)

if chosen_option == "1":

viewapp()

elif chosen_option == "2":

addapp()

elif chosen_option == "3":

summary()

elif chosen_option == "4":

break

else:

print("That was not a valid option, please try again: ")

print("Goodbye")

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值