我是一个 python 菜鸟,我不知道我的代码有什么问题。每当我运行它时,它只会打印出“这是您的密码:”,之后它应该打印出生成的密码。
import random
strength = ['Weak', 'Medium', 'Strong']
charbank = ('1234567890qwertyuiopASDFGHJKLZXCVBNM')
chosenchars = ('')
choice = ('')
def inputfunction():
while True:
userchoice = input("Would you like your password to be: \n Weak \n Medium? \n Strong?\n")
if userchoice in strength:
choice = ''.join(userchoice)
break
print ('oops, that\'s not one of the options. Enter again...')
return choice
def strengththing():
if choice == ("Weak"):
Weak()
if choice == ("Medium"):
Medium()
if choice == ("Strong"):
Strong()
def Weak():
passlen = 5
chosenchars.join(random.sample(charbank, passlen))
def Medium():
passlen = 10
chosenchars.join(random.sample(charbank, passlen))
def Strong():
passlen = 15
chosenchars.join(random.sample(charbank, passlen))
inputfunction()
strengththing()
print ('this is your password: %s' %chosenchars)
任何帮助都会很棒。我不知道我哪里错了。谢谢!