4th Aug 2021, 6:57 PM
Herbert Ink
Herbert Ink - avatar
15 Answers
+ 7
https://code.sololearn.com/cTNB0waXnokz/?ref=app
4th Aug 2021, 7:43 PM
Kirabo Ibrahim
Kirabo Ibrahim - avatar
+ 7
Abhay , BootInk , just to make clear how choices() and "".join() is working (together) ▪︎"".join() can take lists and uses the list elements for creating a new string, as long as all elements of the list are strings ▪︎choices() does not return a list of lists, but just a list of strings if the population used in choices() is also a string, a list of strings,.... sample output of choices(): ['s', '-', '+', 'X', '^', 'S', '|', ')']
4th Aug 2021, 8:23 PM
Lothar
Lothar - avatar
+ 1
NDUHURA HERBERT , can you please give a more detailed description about the tutorial and lesson number from which this question is coming? or copy the complete task description. thanks!
4th Aug 2021, 7:44 PM
Lothar
Lothar - avatar
+ 1
Hey a freind had posted a piece of code on Twitter and I had to try it out
4th Aug 2021, 7:47 PM
Herbert Ink
Herbert Ink - avatar
+ 1
The 4th line is highlighted in the IDE
4th Aug 2021, 7:48 PM
Herbert Ink
Herbert Ink - avatar
+ 1
NDUHURA HERBERT , the line that generates the password can be done like this: (you don't needs a range() and choices gets a random length from k= randint(8,16)) all the rest should work. ... password = "".join(choices(ch, k= randint(8,16))) ...
4th Aug 2021, 8:09 PM
Lothar
Lothar - avatar
0
Check the fourth line well Thats where you are making a mistake
4th Aug 2021, 7:08 PM
Fatoki Temiloluwa
0
choices is returning list and well join method won't work on list , it only concatenates the string items
4th Aug 2021, 7:19 PM
Abhay
Abhay - avatar
0
As mentioned, choices returns a list of lists, rather than just a list of randomly chosen elements. This is problematic because join only works on one dimensional lists. I suggest you define a helper function that can return a one dimensional list of randomly selected characters within your list comprehension, though there might already be a function out there for that purpose...
4th Aug 2021, 7:47 PM
BootInk
BootInk - avatar
0
# Created by NDUHURA HERBERT {2} import string as s from random import * ch = s.ascii_letters + s.digits + s.punctuation password = "".join([choices(ch)[0] for _ in range(randint(8, 16))]) print(password)
6th Aug 2021, 2:16 AM
सत्यम मिश्र
सत्यम मिश्र - avatar
0
If you remove the "s" in choice, the code works. import string as s from random import * ch = s.ascii_letters + s.digits + s.punctuation password = "".join(choice(ch) for x in range(randint(8, 16))) print(password) https://code.sololearn.com/c9qoG6f1R8d9/?ref=app
6th Aug 2021, 3:46 AM
Yamily Fernandez
Yamily Fernandez - avatar
0
Thanks Kirabo Ibrahim
6th Aug 2021, 1:32 PM
SUJIT
SUJIT - avatar
0
I need the help to solve problem code.
8th Aug 2021, 7:34 AM
Ndotarde Casimir
0
What is your code question? 🤔 Send it here so I can see where you are at? Please provide the code link.
8th Aug 2021, 2:19 PM
Yamily Fernandez
Yamily Fernandez - avatar
- 1
while joining a list, you should join by comma like this ",".join(list) i also past through this problem before
5th Aug 2021, 11:55 PM
Winning Godspower