New course! Every coder should learn Generative AI!
Try a free lesson+ 2
Python question
Hello, I make a password generator but I do not understand what this "" .join (choice (chars) I do mainly with the '' .join do? This is the entire code: import string from random import randint, choice letters = string.ascii_letters digits = string.digits symbols = string.punctuation chars = letters + digits + symbols min_length = 8 max_length = 16 password = "" .join (choice (chars) for x in range (randint (min_length, max_length))) print (password) can somebody help me? Thanks.
3 Answers
+ 9
"" same ''
+ 9
as " " same ' '
+ 3
The join() method ( function ) is used to convert a string array ( list ) towards once string in which items from sequence have been joined by the separator ( a string on which you apply the method ).
Well, the expression passed in arguments produce a randomized list of char, and they are joined with a empty string: so they are concatenated ;)