<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Vaarun Sinha</title>
    <description>The latest articles on DEV Community by Vaarun Sinha (@vaarun_sinha).</description>
    <link>https://dev.to/vaarun_sinha</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F741990%2F2aad73e2-d5a9-4cf8-9cdb-21b0f42d0276.jpg</url>
      <title>DEV Community: Vaarun Sinha</title>
      <link>https://dev.to/vaarun_sinha</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vaarun_sinha"/>
    <language>en</language>
    <item>
      <title>Handling errors like a pro in python with sys.excepthook😎</title>
      <dc:creator>Vaarun Sinha</dc:creator>
      <pubDate>Mon, 07 Mar 2022 17:58:00 +0000</pubDate>
      <link>https://dev.to/vaarun_sinha/handling-errors-like-a-pro-in-python-with-sysexcepthook-25oj</link>
      <guid>https://dev.to/vaarun_sinha/handling-errors-like-a-pro-in-python-with-sysexcepthook-25oj</guid>
      <description>&lt;p&gt;As developers, whenever we code we encounter many errors and tracebacks.&lt;/p&gt;

&lt;p&gt;So, how to handle this like a pro with sys.excepthook?&lt;/p&gt;

&lt;p&gt;Well this is what we are going to explore in this blog, so let's began!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.gifer.com%2F75CN.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.gifer.com%2F75CN.gif" alt="Let's Goo (GIF)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Need
&lt;/h2&gt;

&lt;p&gt;Whenever an error occurs the program prints that error and stops right?&lt;/p&gt;

&lt;p&gt;But what if you want to mail that error to a developer or automatically open an issue in a GitHub issues?&lt;/p&gt;

&lt;p&gt;Now many of you will say that we can do that with try and except blocks.&lt;/p&gt;

&lt;p&gt;Yes you can but it would be pretty messy to surround try and except in a python file, or files for bigger projects.&lt;/p&gt;

&lt;p&gt;But with sys.excepthook hook you just have to define a function to handle any error that might pop out.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is sys.excepthook and what does it do?
&lt;/h2&gt;

&lt;p&gt;You can use sys.excepthook to catch errors and do anything with them! &lt;/p&gt;

&lt;p&gt;Excepthook be like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/iOm1xOSfAtPzmPXJqH/giphy-downsized.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/iOm1xOSfAtPzmPXJqH/giphy-downsized.gif" alt="Ladies and gentelmen we got him (GIF)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Basic Example
&lt;/h2&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;imposter_syndrome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;traceback&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;I am a bad coder ☹️&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; of error has occurred, the value: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;, and you can see traceback: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;traceback&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;excepthook&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;imposter_syndrome&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Try Running This Code:&lt;/p&gt;


&lt;div class="ltag__replit"&gt;
  &lt;iframe height="550px" src="https://repl.it/@vaarunSinha/Except-Hook-Tutorial?lite=true"&gt;&lt;/iframe&gt;
&lt;/div&gt;



&lt;p&gt;This was a non-practical but easy to understand example, stay tuned for more real world examples!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/RbDKaczqWovIugyJmW/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/RbDKaczqWovIugyJmW/giphy.gif" alt="Coder (GIF)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Happy Coding!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>python</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>The Art Of Asking Good Questions</title>
      <dc:creator>Vaarun Sinha</dc:creator>
      <pubDate>Thu, 03 Feb 2022 14:17:50 +0000</pubDate>
      <link>https://dev.to/vaarun_sinha/the-art-of-asking-good-questions-lkd</link>
      <guid>https://dev.to/vaarun_sinha/the-art-of-asking-good-questions-lkd</guid>
      <description>&lt;p&gt;As developers, the more code we write the more bugs we have to tackle sometimes we may have just missed a simple semicolon(;) or maybe a typo.&lt;/p&gt;

&lt;p&gt;Most of the times someone already has encountered that problem, and asked on stack overflow so we continue the tradition and copy and paste the first code snippet we see on that stack overflow question into our code.&lt;/p&gt;

&lt;p&gt;But there are sometimes where we encounter truly unique problems / weird errors where no stack overflow answer or google can help us.&lt;/p&gt;

&lt;p&gt;So to solve this problem we ask other developers on public forums, mail groups, discord servers etc...&lt;/p&gt;

&lt;p&gt;To make sure you get help quickly you should know how to ask a great question!&lt;/p&gt;

&lt;p&gt;But before asking make sure that you have properly debugged the code, referred to other Similar stack overflow questions and have researched enough on the topic/problem that you have.&lt;/p&gt;

&lt;p&gt;Here are DOs and DONTs of asking question:&lt;/p&gt;

&lt;p&gt;DOs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Have a good title that summarises the problem.&lt;/li&gt;
&lt;li&gt;Keep the content short.&lt;/li&gt;
&lt;li&gt;Create a live online environment on REPLIT or other similar online platforms.&lt;/li&gt;
&lt;li&gt;Provide operating system, framework/language version and relevant code.&lt;/li&gt;
&lt;li&gt;Copy and paste only the error value not the whole file system traceback.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;DONTs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Don't ask to ask just ask! Visit: &lt;a href="https://dontasktoask.com"&gt;https://dontasktoask.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Don't provide the whole code, only the relevant parts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is a sample question that uses the above principles.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sample Question
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Title&lt;/strong&gt;: Why does 1 + 1 = 11 in python?&lt;br&gt;
&lt;strong&gt;Tags&lt;/strong&gt;: #python&lt;br&gt;
&lt;strong&gt;Error&lt;/strong&gt;: When I add 1 and 1 in this program it prints 11 rather than the expected result of 2.&lt;br&gt;
Code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;num_1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Enter number: "&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;num_2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Enter number: "&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;num_2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OS: Mac OS (M1 Chip)&lt;br&gt;
Python version: 3.9.4&lt;br&gt;
Live Environment To Run The Code:&lt;br&gt;
&lt;a href="https://replit.com/@vaarunSinha/Asking-Questions-Example#main.py"&gt;https://replit.com/@vaarunSinha/Asking-Questions-Example#main.py&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank You For taking time to read this question. Please help me out.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The above question is really good, but here's the one and only problem with this question, that if I had researched enough I would have got the answer that actually I was adding strings.&lt;/p&gt;

&lt;p&gt;I could not find a better example that's why 😅&lt;/p&gt;

&lt;p&gt;I hope from now you will ask great questions as a developer!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Happy Debugging&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>My first hackathon went horribly wrong!</title>
      <dc:creator>Vaarun Sinha</dc:creator>
      <pubDate>Sun, 26 Dec 2021 12:58:51 +0000</pubDate>
      <link>https://dev.to/vaarun_sinha/my-first-hackathon-went-horribly-wrong-3hkn</link>
      <guid>https://dev.to/vaarun_sinha/my-first-hackathon-went-horribly-wrong-3hkn</guid>
      <description>&lt;p&gt;My first hackathon went horribly wrong! Few tips to avoid this.&lt;/p&gt;

&lt;p&gt;So, I attended a hackathon, (I am not gonna take the name of the hackathon)and it went horribly wrong, and here's how:&lt;/p&gt;

&lt;p&gt;So I found 3 people to be my team, one was a illustrator with great project ideas, one was a beginner frontend developer with HTML CSS and JS skills and the other one knew HTML &amp;amp; CSS a bit but was more comfortable in python and Django. So I somehow pushed/forced then (by continuous messages) to join a google meets call,  we discussed what to do, and divided the work, now here is when the problem begins…&lt;/p&gt;

&lt;p&gt;The next day when I asked everyone, to post there progress, as there were only 5 hours till the deadline, and the person, that agreed to do the main component of the project, just turned in copied code! Everything was copied from GitHub and then went offline! The other person, mysteriously disappeared! Both of them did not come online, even after continuous messaging! Only me and the illustrator were online, so there were now only 2 hours left, I decided that I will at least submit a project!&lt;/p&gt;

&lt;p&gt;So after around 30 mins of brainstorming, I decided to build a discord bot, but I had no idea how to build one! So I started watching a freecodecamp tutorial, that was 1 hour long, but then I realised well, I did not have any time for that! So I jumped straight into docs and made it work.&lt;/p&gt;

&lt;p&gt;But there was another problem, I did not know how to request data from APIs, and work with that data, this was crucial; as basically what the discord bot did, is retrieve data from several APIs, and send messages.&lt;/p&gt;

&lt;p&gt;So I learnt the requests library, and the json library. &lt;/p&gt;

&lt;p&gt;“Growth happens outside of the comfort zone”&lt;/p&gt;

&lt;p&gt;I found that this thing really true, Because I learnt discord.py, requests, and the Json library under these conditions, and implemented them directly in my project, I don’t think I will ever forget these libraries and concepts.&lt;/p&gt;

&lt;p&gt;But don’t worry this horrible experience at this hackathon, did not stop me from registering for another hackathon!&lt;/p&gt;

&lt;p&gt;If you are organise events/hackathons then please read this:&lt;br&gt;
This thing really annoyed me in the hackathon that whenever I would ask any query they would be online on discord, but they would neither reply, nor type anything!  And they promised everyone a sticker, but now they are saying that international shipping will be not available!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Don’t make false promises&lt;/li&gt;
&lt;li&gt;  Reply to queries ASAP&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want to be a good hackathon participant :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Take the work if you know how to do it, and will be able to do it in time&lt;/li&gt;
&lt;li&gt;  Don’t turn in copied code&lt;/li&gt;
&lt;li&gt;  Try to be online most of the time in the hackathon.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What I learnt:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Json standard library&lt;/li&gt;
&lt;li&gt;  Requests standard library&lt;/li&gt;
&lt;li&gt;  Discord.py&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>My Second Hackathon Was Awesome! Here are some tips for a great hackathon.</title>
      <dc:creator>Vaarun Sinha</dc:creator>
      <pubDate>Tue, 30 Nov 2021 15:30:28 +0000</pubDate>
      <link>https://dev.to/vaarun_sinha/my-second-hackathon-was-awesome-here-are-some-tips-for-a-great-hackathon-320m</link>
      <guid>https://dev.to/vaarun_sinha/my-second-hackathon-was-awesome-here-are-some-tips-for-a-great-hackathon-320m</guid>
      <description>&lt;p&gt;So we started with our amazing Idea educrypt, though none of us knew how to make a discord bot, except me I had little knowledge... Our project was based on discord and the web. &lt;/p&gt;

&lt;p&gt;You know why this hackathon was successful?  Because of team work.&lt;/p&gt;

&lt;p&gt;So here are some tips for a successful team:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Be respectful to each other.&lt;/li&gt;
&lt;li&gt;Listen to every idea, then decide.&lt;/li&gt;
&lt;li&gt;Don't be stubborn&lt;/li&gt;
&lt;li&gt;Give your own ideas&lt;/li&gt;
&lt;li&gt;Complete the work assigned to you&lt;/li&gt;
&lt;li&gt;And have fun!&lt;/li&gt;
&lt;li&gt;Contribute&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can see, our project on devpost: &lt;a href="https://devpost.com/software/educrypt"&gt;https://devpost.com/software/educrypt&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Also the organisers were always active in discord, and were really helpful.&lt;/p&gt;

&lt;p&gt;So great team + great organisers are the main elements which identify a great hackathon experience.&lt;/p&gt;

&lt;p&gt;Here are some things to consider before teaming with other people:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Time zone,(if they are dedicated and can meet in early morning or late nights then this does not matter)&lt;/li&gt;
&lt;li&gt;Skills (Do they have skills, similar to yours? Even if they have only some skills, if they can learn new things fast, then this does not matter also.)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So I hope that you win your next hackathon, till then:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Coding&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>python</category>
      <category>hackathon</category>
      <category>teamwork</category>
    </item>
    <item>
      <title>Thanks For 100 Followers!</title>
      <dc:creator>Vaarun Sinha</dc:creator>
      <pubDate>Sat, 27 Nov 2021 14:38:19 +0000</pubDate>
      <link>https://dev.to/vaarun_sinha/thanks-for-100-followers-24e8</link>
      <guid>https://dev.to/vaarun_sinha/thanks-for-100-followers-24e8</guid>
      <description>&lt;p&gt;I had recently started posting on dev.to, just at the start of this month, I have posted 5 posts (excluding this one), I did not expect such good response. I don't know if 100 followers are more or less on dev.to but I am truly grateful for that I just want to say one thing:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thank You!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>thanks</category>
      <category>offtopic</category>
    </item>
    <item>
      <title>Why Conferences Can Be So Important For You, As A Developer.</title>
      <dc:creator>Vaarun Sinha</dc:creator>
      <pubDate>Wed, 24 Nov 2021 12:55:44 +0000</pubDate>
      <link>https://dev.to/vaarun_sinha/why-conferences-can-be-so-important-for-you-as-a-developer-18h8</link>
      <guid>https://dev.to/vaarun_sinha/why-conferences-can-be-so-important-for-you-as-a-developer-18h8</guid>
      <description>&lt;p&gt;Alright, So now you are probably wondering that why conferences matter, here are some benefits of attending a conference:&lt;/p&gt;

&lt;h2&gt;
  
  
  Job Opportunities
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If you are looking for a job, then the best place to look for are conferences, 
most of the time, in these conferences there are partners called ”Hiring Partners”, these are companies which are looking for employees. Their own agents wander and interact with everyone like normal, but when they feel you are the right person for the job, they request you to send your resume! So represent yourself nicely. I have seen a person get an interview from a reputed company at djangocon2021, myself! He did not have any degree he was self taught, so that does not matter!&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Meeting Like Minded People.
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In a conference, you find many like minded people, love python? There will be others who love python there as well! This will lead to constructive discussions, which will change your perspective and knowledge. You can tackle problems together and come to a solution also. You can make friends there! And find people to collaborate with!&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Giveaways/Swags
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;This is not  more valuable than the previous point but it is a plus point, in most of these conferences there are many giveaways.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Knowledge
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;This is the most important point of all, when you attend these conferences you build your knowledge, you learn from fellow speakers or even the attendees.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Personal Branding/Identity
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Conferences are the best place to showcase your skills, projects or Saas products, because you can never know if you are talking to a future client, employer, partner, or consumer. For example, I am now thinking of buying a Saas product, because of the way the person I talked to presented himself and his product.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So now you know why conferences can be very important for you as a developer.&lt;/p&gt;

&lt;p&gt;Before you leave reading this blogpost, i would highly recommend a conference which I am also attending:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Git Commit Show&lt;/strong&gt; it’s the world’s largest  2 day conference from November 27 to 28, where you can meet with senior engineers,researchers, scientists, and professors while being at home!&lt;/p&gt;

&lt;p&gt;It has all the perks i mentioned earlier, dedicated discord channels for networking, giveaways, and job opportunities!&lt;/p&gt;

&lt;p&gt;So I hope I will meet you there at the git commit show!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.google.com/forms/d/e/1FAIpQLSdFuHEOT9i5KBEOL56nbwn6HNGpsgGL55JGwwXYFdjC4kqnHw/viewform"&gt;&lt;strong&gt;Register Now&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Know more here:&lt;/strong&gt; &lt;a href="https://gitcommit.show"&gt;https://gitcommit.show&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Coding&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>gitcommitshow</category>
      <category>beginners</category>
      <category>opensource</category>
    </item>
    <item>
      <title>What is random.shuffle() method in python? How to use it?</title>
      <dc:creator>Vaarun Sinha</dc:creator>
      <pubDate>Thu, 18 Nov 2021 13:53:24 +0000</pubDate>
      <link>https://dev.to/vaarun_sinha/what-is-randomshuffle-method-in-python-how-to-use-it-57o5</link>
      <guid>https://dev.to/vaarun_sinha/what-is-randomshuffle-method-in-python-how-to-use-it-57o5</guid>
      <description>&lt;p&gt;In this blog, we will explore the random.shuffle method in python, and implement this method in our password generator project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So Let's Get Started!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What is the random.shuffle method? &lt;/p&gt;

&lt;p&gt;Basically the random.shuffle methods takes in a list like:&lt;br&gt;
[1, 2, 3, 4, 5, 6, 7, 8, 9] and shuffles it like: 2, 1, 5, 6, 8, 9, 4, 7, 3].&lt;/p&gt;

&lt;p&gt;Run this code to know more:&lt;/p&gt;


&lt;div class="ltag__replit"&gt;
  &lt;iframe height="550px" src="https://repl.it/@vaarunSinha/Random-Shuffle-Method?lite=true"&gt;&lt;/iframe&gt;
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Let's implement this in our own project!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the previous blog, we had a problem:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Now if we print/generate the password every time ,there is a &lt;br&gt;
predictable format, first numbers then special etc..&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So for that first let's convert the password into a list:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numPart&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;spPart&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;smallPart&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;bigPart&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shuffle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;password_str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;''&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;password_str&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This is the final code for a basic password generator!&lt;/p&gt;


&lt;div class="ltag__replit"&gt;
  &lt;iframe height="550px" src="https://repl.it/@vaarunSinha/Password-Generator-with-secrets-module?lite=true"&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;So stay tuned!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Coding!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>projects</category>
    </item>
    <item>
      <title>How to make a password generator with python.</title>
      <dc:creator>Vaarun Sinha</dc:creator>
      <pubDate>Thu, 18 Nov 2021 09:32:09 +0000</pubDate>
      <link>https://dev.to/vaarun_sinha/how-to-make-a-password-generator-with-python-2b1a</link>
      <guid>https://dev.to/vaarun_sinha/how-to-make-a-password-generator-with-python-2b1a</guid>
      <description>&lt;p&gt;In this tutorial we will make a password generator with the secrets module. Why not random module? see the first post in this series to understand.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So Let's Begin!&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Generate a random password, according to the user input.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sub problems
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Get user input&lt;/li&gt;
&lt;li&gt;Create lists for letters etc...&lt;/li&gt;
&lt;li&gt;Loop over lists and make a password.&lt;/li&gt;
&lt;li&gt;Print the password.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Let's write some code!
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Get user input
Here we will use try/except blocks so that when user types a string we do not get an error.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We will get inputs for number of special characters, small letters, big letters and numbers required for generating the password.&lt;/p&gt;

&lt;p&gt;Code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;num_of_numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"How many numbers should your password have: "&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;num_of_numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"How many numbers should your password have: "&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;num_of_special&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"How many special characters should your password have: "&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;num_of_special&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"How many special characters should your password have: "&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;num_of_small_letters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"How many small letters should your password have: "&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;num_of_small_letters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"How many small letters should your password have: "&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;num_of_cap_letters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"How many big letters should your password have:  "&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;num_of_cap_letters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"How many big letters should your password have:  "&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;### Create Lists for numbers to choose from. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We could hardcode this like:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;number_list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;But this will take us way more time!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;So let's use the string module!&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;string&lt;/span&gt;
&lt;span class="n"&gt;number_list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;digits&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But we could just have a string right? then why make it list you will find this out later on in this blog!&lt;/p&gt;

&lt;p&gt;Let's do this for everything.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;string&lt;/span&gt;

&lt;span class="n"&gt;smallLetters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ascii_lowercase&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;bigLetters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ascii_uppercase&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;specialCharacters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;punctuation&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;digits&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So now we can loop over these lists, and make a list!&lt;/p&gt;

&lt;p&gt;First let's declare empty variables!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;spPart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;

&lt;span class="n"&gt;numPart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;

&lt;span class="n"&gt;smallPart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;

&lt;span class="n"&gt;bigPart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's loop over the lists.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_of_numbers&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;randNum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;secrets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;choice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;numPart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;numPart&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;randNum&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_of_special&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;randSp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;secrets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;choice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;specialCharacters&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;spPart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;spPart&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;randSp&lt;/span&gt;


    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_of_small_letters&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;randSm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;secrets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;choice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;smallLetters&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;smallPart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;smallPart&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;randSm&lt;/span&gt;


    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_of_cap_letters&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;randBig&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;secrets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;choice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bigLetters&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;bigPart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;bigPart&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;randBig&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's add the parts to make a password.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;numPart&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;spPart&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;smallPart&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;bigPart&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's refactor the code, by putting this into a function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;generate_password&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="n"&gt;num_of_numbers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_of_special&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_of_small_letters&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_of_cap_letters&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;

    &lt;span class="n"&gt;smallLetters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ascii_lowercase&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;bigLetters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ascii_uppercase&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;specialCharacters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;punctuation&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;digits&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;spPart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;

    &lt;span class="n"&gt;numPart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;

    &lt;span class="n"&gt;smallPart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;

    &lt;span class="n"&gt;bigPart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;

    &lt;span class="c1"&gt;# ANCHOR: Generating Password
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_of_numbers&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;randNum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;secrets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;choice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;numPart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;numPart&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;randNum&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_of_special&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;randSp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;secrets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;choice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;specialCharacters&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;spPart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;spPart&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;randSp&lt;/span&gt;


    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_of_small_letters&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;randSm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;secrets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;choice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;smallLetters&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;smallPart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;smallPart&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;randSm&lt;/span&gt;


    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_of_cap_letters&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;randBig&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;secrets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;choice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bigLetters&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;bigPart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;bigPart&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;randBig&lt;/span&gt;

    &lt;span class="n"&gt;password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;numPart&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;spPart&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;smallPart&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;bigPart&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;So how we can solve this?&lt;/p&gt;

&lt;p&gt;We will solve this in the next short blog coming very quickly after this blog, so stay tuned!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Happy Coding!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>project</category>
      <category>security</category>
    </item>
    <item>
      <title>Why you should never use random module for generating passwords.</title>
      <dc:creator>Vaarun Sinha</dc:creator>
      <pubDate>Thu, 04 Nov 2021 09:43:19 +0000</pubDate>
      <link>https://dev.to/vaarun_sinha/why-you-should-never-use-random-module-for-generating-passwords-38nl</link>
      <guid>https://dev.to/vaarun_sinha/why-you-should-never-use-random-module-for-generating-passwords-38nl</guid>
      <description>&lt;h2&gt;
  
  
  Why Random Numbers Are Not Random?
&lt;/h2&gt;

&lt;p&gt;The Random Numbers come from a particular seed number which is usually the system clock.Run the program below to understand the security risk.&lt;/p&gt;


&lt;div class="ltag__replit"&gt;
  &lt;iframe height="550px" src="https://repl.it/@MRINDIA1/Random-Numbers-Are-Not-Random?lite=true"&gt;&lt;/iframe&gt;
&lt;/div&gt;


&lt;p&gt;The Python Documentation also has a warning about the same: "The &lt;strong&gt;pseudo-random&lt;/strong&gt; generators of this module &lt;strong&gt;should not be used for security purposes&lt;/strong&gt;."&lt;/p&gt;

&lt;p&gt;So all the password generators you have built using random module are not secure!? So How do we generate cryptographically secure numbers/passwords?&lt;/p&gt;

&lt;p&gt;But there is another line after that warning:&lt;br&gt;
"&lt;em&gt;For security or cryptographic uses, see the secrets module.&lt;/em&gt;"&lt;/p&gt;

&lt;h2&gt;
  
  
  What is this secrets module?
&lt;/h2&gt;

&lt;p&gt;The secrets module is used for generating cryptographically strong random numbers suitable for managing data such as passwords, account authentication, security tokens, and related secrets. &lt;/p&gt;

&lt;h3&gt;
  
  
  How it is different from the random module?
&lt;/h3&gt;

&lt;p&gt;I found a really good post on reddit from which you can understand what is the difference between these two modules.&lt;/p&gt;

&lt;p&gt;The Post says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"with random your numbers come from some seed number, usually based on the system clock, which generates pseudo-random numbers. That means that if you get guess the seed, you can generate the same sequence of numbers. If you used pseudorandomly generated numbers as salts for all your passwords, then brute forcing the keys would become trivial.&lt;br&gt;
true random numbers come from "high entropy" seeds, meaning it's not just some number you can guess, it's things that are impossible to reproduce algorithmically. Imagine things like keyboard inputs, time between keystrokes, mouse movements, cpu usage, number of programs running, etc. It might not use those exactly, but you can see how the numbers it generates from those sources are literally impossible to reproduce which is why you want to use those ones as your encryption keys and salts."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And another post says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"It's more secure because it's less predictable. The random module uses an algorithm that's fast but it's possible to calculate what the next random number will be. That's fine for randomly placing things on the screen or something but for generating passwords it's important that the number is not predictable."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So basically it makes the seed really hard to guess( less predictable) &lt;/p&gt;

&lt;p&gt;Reddit Post 1: &lt;a href="https://www.reddit.com/r/learnpython/comments/7w8w6y/comment/dtyg7wd/?utm_source=share&amp;amp;utm_medium=web2x&amp;amp;context=3"&gt;https://www.reddit.com/r/learnpython/comments/7w8w6y/comment/dtyg7wd/?utm_source=share&amp;amp;utm_medium=web2x&amp;amp;context=3&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Reddit Post 2:&lt;br&gt;
&lt;a href="https://www.reddit.com/r/learnpython/comments/7w8w6y/comment/dtyi6z8/?utm_source=share&amp;amp;utm_medium=web2x&amp;amp;context=3"&gt;https://www.reddit.com/r/learnpython/comments/7w8w6y/comment/dtyi6z8/?utm_source=share&amp;amp;utm_medium=web2x&amp;amp;context=3&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stay tuned for the next blog where we make a password generator which generates cryptographically strong passwords.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Happy Coding&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>programming</category>
      <category>security</category>
    </item>
    <item>
      <title>Python Program To Find If A word/number is a palindrome or not.</title>
      <dc:creator>Vaarun Sinha</dc:creator>
      <pubDate>Mon, 01 Nov 2021 07:34:09 +0000</pubDate>
      <link>https://dev.to/vaarun_sinha/python-program-to-find-if-a-wordnumber-is-a-palindrome-or-not-3j2o</link>
      <guid>https://dev.to/vaarun_sinha/python-program-to-find-if-a-wordnumber-is-a-palindrome-or-not-3j2o</guid>
      <description>&lt;h2&gt;
  
  
  What Is A Palindrome?
&lt;/h2&gt;

&lt;p&gt;Like every programmer does, let's google it! &lt;br&gt;
😉 &lt;br&gt;
&lt;strong&gt;&lt;em&gt;googles&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
A word, phrase, or sequence that reads the same backwards as forwards, e.g madam or nurses run.&lt;/p&gt;
&lt;h2&gt;
  
  
  Problem
&lt;/h2&gt;

&lt;p&gt;To find if a word/number is a palindrome or not.&lt;/p&gt;
&lt;h3&gt;
  
  
  Sub Problems
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Get user input.&lt;/li&gt;
&lt;li&gt;Check if the input is an integer or string.&lt;/li&gt;
&lt;li&gt;Reverse the input.&lt;/li&gt;
&lt;li&gt;Check if the initial input is same as the reversed one.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Pseudo Code
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Input = GetUserInput()
reversed_input = reverse(input)

if Input is equal to reversed_input:
print("It Is A Palindrome Number")
else:
print("it is not a palindrome number")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Let's Finally Code It!
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Get User Input
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;userInputw&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Enter The Value:&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;#w for with whitespace
&lt;/span&gt;&lt;span class="n"&gt;userInput&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;userInputw&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;#removing whitespace so we can test for phrases like nurses run.
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Reverse The Input
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;reversedInput&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;userInput&lt;/span&gt;&lt;span class="p"&gt;[::&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Check If The Initial Input is same as the reversed one.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;reversedInput&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;userInput&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;userInput&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; is equal to it's reverse &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;reversedInput&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; therefore it is a palindrome number."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
     &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;userInput&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; is not equal to it's reverse &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;reversedInput&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; therefore it is not a palindrome number."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Making the Code Reusable
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;To make the code reusable let's put the logic in a function.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;reverse_value&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
 &lt;span class="n"&gt;reversedValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;[::&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
 &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;reversedValue&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;is_palindrome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
   &lt;span class="n"&gt;reversedValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;reverse_value&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;reversedValue&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
         &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Full Code
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;reverse_value&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
 &lt;span class="n"&gt;reversedValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;[::&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
 &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;reversedValue&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;is_palindrome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;reversedValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;reverse_value&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;reversedValue&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
         &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;

&lt;span class="n"&gt;userInputw&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Enter The Value:&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;userInput&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;userInputw&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;isPalindrome&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;is_palindrome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;userInput&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;isPalindrome&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;userInputw&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; is equal to it's reverse &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;userInputw&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; therefore it is a palindrome."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
     &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;userInput&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; is not equal to it's reverse &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;reverse_value&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;userInput&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; therefore it is not a palindrome."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Key Takeaways:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[::-1] Reverses a string.&lt;/li&gt;
&lt;li&gt;string.replace(" ", "") replaces all whitespaces with no whitespaces.&lt;/li&gt;
&lt;li&gt;Before jumping right into code, break the problem Into sub problems then do some pseudo code, then write the code. After That You can optimise it.&lt;/li&gt;
&lt;li&gt;Implement this if the problem is hard or you cannot exactly think what to code. or else it is a time waster for easy problems.&lt;/li&gt;
&lt;li&gt;Make The Code Reusable.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Run it on repl
&lt;/h2&gt;


&lt;div class="ltag__replit"&gt;
  &lt;iframe height="550px" src="https://repl.it/@MRINDIA1/Palindrome?lite=true"&gt;&lt;/iframe&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  Github: &lt;a href="https://github.com/Dev2212/Palindrome-Finder-In-Python"&gt;https://github.com/Dev2212/Palindrome-Finder-In-Python&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;HAPPY CODING!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
