Python question | Sololearn: Learn to code for FREE!
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.

18th Jan 2017, 10:07 PM
bliksem070
bliksem070 - avatar
3 Answers
+ 9
"" same ''
19th Jan 2017, 7:00 AM
Sergey
+ 9
as " " same ' '
19th Jan 2017, 7:00 AM
Sergey
+ 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 ;)
19th Jan 2017, 7:24 AM
visph
visph - avatar