mercredi 16 juin 2021

While making this random password generator, using the python library random_word, the "random word" in the elif statement sometimes returns "None"

import numpy as np
from random_word import RandomWords
r = RandomWords()

promptInput = str(input("Do you want to enter your on prompt or randomly generate it, answer 
in yes or no : "))

if promptInput == "yes" :
    passwordHint = str(input("Enter a prompt for making the password : "))
    nums = np.random.randint(1000, 9999)
    newHint = passwordHint.capitalize()
    nums = str(nums)

    password = newHint + nums
    print(password)

elif promptInput == "no" :
    randomWord = str(r.get_random_word(minLength = 5,maxLength = 7))
    nums = np.random.randint(1000, 9999)
    newRandomWord = randomWord.capitalize() 
    nums = str(nums)

    password2 = newRandomWord + nums
    print(password2)                       

printing this is mostly returning "None" and then the random numbers, for example - None8797

else :
    print("Enter yes or no only")

This could also be a problem as I previously wanted to test if the code would work, so I typed out in the elif statement print("none")




Aucun commentaire:

Enregistrer un commentaire