DEV Community

Vaarun Sinha
Vaarun Sinha

Posted on • Edited on

3 1

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
Enter fullscreen mode Exit fullscreen mode

This is the final code for a basic password generator!



So stay tuned!

Happy Coding!

Image of AssemblyAI tool

Transforming Interviews into Publishable Stories with AssemblyAI

Insightview is a modern web application that streamlines the interview workflow for journalists. By leveraging AssemblyAI's LeMUR and Universal-2 technology, it transforms raw interview recordings into structured, actionable content, dramatically reducing the time from recording to publication.

Key Features:
🎥 Audio/video file upload with real-time preview
🗣️ Advanced transcription with speaker identification
⭐ Automatic highlight extraction of key moments
✍️ AI-powered article draft generation
📤 Export interview's subtitles in VTT format

Read full post

Top comments (1)

Collapse
 
vaarun_sinha profile image
Vaarun Sinha

Feedback is highly appreciated, if you find any problem/mistakes (which is unlikely) then please comment the problem and I will fix it.

Hope you learnt something valuable today.

Hope You Have A Nice Day Ahead!

Happy Coding!

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay