![]() Password.append(random.choice(special_characters)) Password.append(random.choice(alphabets))įor i in range(special_characters_count): Print("Characters total count is greater than the password length") # print not valid if the sum is greater than length # check the total length with characters sum count Special_characters_count = int(input("Enter special characters count in password: "))Ĭharacters_count = alphabets_count + digits_count + special_characters_count Special_characters = list(" #$%^&*()")Īlphabets_count = int(input("Enter alphabets count in password: "))ĭigits_count = int(input("Enter digits count in password: ")) Let’s see the code that accepts the number of characters for each type and generates the password. When the user enters the number of characters for each type, the program will include the respective number of character types into the password. Next, we try to guarantee that the program will include digits and special characters by asking the user to enter the number of digits, alphabets, and special characters they want. ![]() Because there is no guarantee that the program will include digits. Observe the password in the above output. Now, run the code and generate a password. So, you won’t find any problem in understanding the code if you read the steps. We have just followed the steps described to write code. Password.append(random.choice(characters)) # picking random characters from the list Length = int(input("Enter password length: ")) Code import stringĬharacters = list(string.ascii_letters + string.digits + " #$%^&*()") Don’t worry, even if you are not able to write the code.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |