1
シンプルなパスワードジェネレータを作成しようとしていますが、私の機能は私の意図する結果や結果を与えてくれません。私。追加して空のリストを展開しないでください。私は何かを変えるべきですか?私の機能がうまくいかない理由は何ですか?
import random
def passstrength():
return input("Please state how strong you have the password to be? (1 = strongest, 2 = medium, 3 = weakest): ")
passstrength = passstrength()
list1 = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','q','r','s','t','u','v','x','y','z']
list2 = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','Q','R','S','T','U','V','X','Y','Z']
list3 = [1,2,3,4,5,6,7,8,9,0]
list4 = ["@","$","%","&"]
r = []
def getpass(x):
return random.sample(x,2)
def mergepass(first,second,third):
if passstrength == 1:
a = getpass(first)
b = getpass(second)
c = getpass(third)
r = (a + b + c)
return r
elif passstrength == 2:
a = getpass(first)
b = getpass(second)
r = (a + b)
return r
else:
a = getpass(first)
r = (a)
return r
print (mergepass(list1,list2,list3))