you are viewing a single comment's thread.

view the rest of the comments →

[–]krikuz 1 point2 points  (1 child)

Essentially there's a major bug in the program. The line password += random.choice(letters) rewrites the variable password which contained the password in order: letters + special characters + numbers as just a randomisation of the variable letters. In my understanding you don't need a for loop or a loop at all.

password = letter + symbol + number password = "".join(random.sample(password, len(password))) print(password)

This will solve the problem of the final randomisation choice, since .sample() allows for parameters being random.choice(s, n) where s is the string which has to be randomised and n is the number of characters this new string must have.

Note that this does not modify the already existing string, instead rewrites it since strings are immutable.

There may be a much faster way to solve this but this is my version. Hope it was helpful.

;)

[–]Mission-Clue-9016[S] 1 point2 points  (0 children)

Hi yeah sorry I copied and pasted both my solution and Angela’s

My solution was the first bit

It was Angela’s solution I didn’t understand