+ 3

Can I make random letters using Python and How??

I am thinking of making a password Generator program by combining random numbers and letters.I recently learnt how to create random numbers in Python by importing a module named 'Random'.Now I need to know how to make random letters to combine with random numbers to create a password

18th Apr 2020, 1:49 PM
Tobby
Tobby - avatar
4 Respostas
+ 4
To generate ramdom characters and special characters you can use the modul ramdom. Import choice or choices from this module. Then create a list or a string LS with all characters you wanted to use. By using random.choice you define LS, and run this in a loop to get n characters out of LS. By using random.choices you can generate the resulting characters without using a loop, but you can pass an argument k = 10 to get 10 characters. It is also possible to give a weights argument.
18th Apr 2020, 3:07 PM
Lothar
Lothar - avatar
+ 1
You can use lists to do so.
18th Apr 2020, 2:22 PM
Pranav
Pranav - avatar