What is random.shuffle() method in python? How to use it?

In this blog, we will explore the random.shuffle method in python, and implement this method in our password generator project.

So Let’s Get Started!

What is the random.shuffle method?

Basically the random.shuffle methods takes in a list like:
[1, 2, 3, 4, 5, 6, 7, 8, 9] and shuffles it like: 2, 1, 5, 6, 8, 9, 4, 7, 3].

Run this code to know more:

Let’s implement this in our own project!

In the previous blog, we had a problem:

Now if we print/generate the password every time ,there is a
predictable format, first numbers then special etc..

So for that first let’s convert the password into a list:

password = list(numPart + spPart + smallPart + bigPart)
random.shuffle(password)
password_str = ''.join(password)
return password_str

Done! Simple Right?

But what if the user forgets the password and wants to access it? we will build that functionality later on! in the next blog which will come in 2 weeks!

This is the final code for a basic password generator!

So stay tuned!

Happy Coding!


Source link

Single feature app idea – DEV Community

Here’s an idea for a side project: Take one painful, labourious, repetitive task on Photoshop/Indesign/Sketch/Final Cut Pro/any editing software for that matter, and make that into a product.

Like this nifty little remove.bg web app. I love it. Removing backgrounds can already be done in Photoshop for sure, but to do it well (especially removing background from hair), it does take some manual effort. And it’s a task that happens pretty often enough to feel quite repetitive, boring and simply an unproductive use of time after a while. Software automation is great for tasks of such nature – manual, labourious, simple-enough, repetitive, boring.

I remember reading somewhere that Invision was built to facilitate client feedback, to make screen prototypes more shareable so that it’s easy for anyone (even non-designers) to comment. Imagine the loss of productivity from endless emailing of pdfs back and forth, versioning the different files each time – clientwebsite-final-final-final.pdf. Again, Invision replaces one repetitive, labourious and painful task of communication ping-pong into a product. Same with Google Docs.

This idea for a single feature app or software product sounds so simple, yet so difficult to practice because everyday routine and habit blinds us to opportunities like these. So this made me think:

What boring, painful and simple work tasks that we do repetitively and manually on a regular basis, can be replaced by automation/software?

Let’s hear it!


Follow my daily writings on Lifelog, where I write about learning to code, goals, productivity, indie hacking and tech for good.


Source link