I am a python noob and I don't know what's wrong with my code. Whenever I run it it just prints out "this is your password: " with nothing after that when it is supposed to print out the generated password.
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)
Any help would be great. I don't know where I went wrong. Thank you!
You didn't change the value of 'choice' with your return statement after your While loop.
I did a few modifications.
There you go :