Password Generator | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Password Generator

Created my first password generator (one of my first program) like it? :D https://code.sololearn.com/cRHsubgX32zL/?ref=app

27th May 2018, 2:44 PM
Jessica
Jessica - avatar
8 Answers
+ 1
I have a few improvements you could do to make the code better. Firstly you don’t have to make 7 lists that are the same, you can just use 1 in the program. You should also store the characters as a string making it easier to change ect. Putting the random generation in a loop wouldn’t hurt too.
27th May 2018, 2:57 PM
TurtleShell
TurtleShell - avatar
+ 1
how do i put it in a loop?
27th May 2018, 2:58 PM
Jessica
Jessica - avatar
0
Could you remake it ?
27th May 2018, 3:02 PM
Jessica
Jessica - avatar
0
Actually you could use a loop or list comprehension (which you probably haven’t learned yet) Loop: for _ in range(how many characters you want): print(random.choice(characters), end="") # end tells the print function what the last character should be (default is \n) in this case its nothing List comprehension: print("".join([random.choice(characters) for _ in range(how many characters you want)]))
27th May 2018, 3:04 PM
TurtleShell
TurtleShell - avatar
27th May 2018, 3:06 PM
TurtleShell
TurtleShell - avatar
0
thanks :)
27th May 2018, 3:08 PM
Jessica
Jessica - avatar
0
My passwords Generator with your own alphabet) https://code.sololearn.com/ckU6p3GEKblP/?ref=app
12th Jun 2018, 4:31 PM
Ox22B8
Ox22B8 - avatar