<?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: Vishesh Dvivedi</title>
    <description>The latest articles on DEV Community by Vishesh Dvivedi (@visheshdvivedi).</description>
    <link>https://dev.to/visheshdvivedi</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%2F738429%2F898db374-c07f-4202-83dc-5ecbc20ab9ed.jpg</url>
      <title>DEV Community: Vishesh Dvivedi</title>
      <link>https://dev.to/visheshdvivedi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/visheshdvivedi"/>
    <language>en</language>
    <item>
      <title>How to automate excel creation in Python</title>
      <dc:creator>Vishesh Dvivedi</dc:creator>
      <pubDate>Sun, 09 Jan 2022 12:33:03 +0000</pubDate>
      <link>https://dev.to/visheshdvivedi/how-to-automate-excel-creation-in-python-1i4n</link>
      <guid>https://dev.to/visheshdvivedi/how-to-automate-excel-creation-in-python-1i4n</guid>
      <description>&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/9ALJlSV3Dzw"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Programmers often deal with a LOT OF DATA. And if you are a Python programmer, or wish to become one, you will eventually have to deal with storing the program’s output data in an efficient way, be it web scraping, AI ML, we dev, or automation script.&lt;/p&gt;

&lt;p&gt;Although saving data in files like txt, JSON, XML or HTML  is nice, it may not provide a way to analyze the data easily. And that’s where excel files can be a big game-changer. Since excel files can be analyzed, and the data within them can be easily sorted or trimmed based on needs, with the help of software like Microsoft Excel, these files provide a user-friendly way to store data.&lt;/p&gt;

&lt;p&gt;What’s up Pythoneers’ this is Vishesh Dvivedi and in this post, we are gonna learn how you can create excel files in python and how you can store data in them. This post will specifically focus on creating and storing data in excel files. If you guys want a post on reading data from an excel file, then do mention it in the comments below and I will make a post on it.&lt;/p&gt;

&lt;p&gt;So without any further ado, let’s begin&lt;/p&gt;

&lt;p&gt;So we are gonna start off with an empty python script right here. You can name the script whatever you want, I just named it excel.py. Now to start off, we will first import a module named xlsxwriter. This is a module you can find in python module packages, which is used to create excel files in python. You may find many other modules too that could do the same work, but I personally find this one to be the most commonly used and easy to understand. &lt;/p&gt;

&lt;p&gt;First, you need to open the command prompt and type&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install xlsxwriter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This command will install the xlsxwriter module onto your local system. Once that’s done, you can go back to your text editor (BTW i am using visual studio code, you can any IDE or text editor you want) and then type&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import xlsxwriter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This line will import the xlsxwriter module onto our script, so that we can use all the classes and functions present within the module.&lt;/p&gt;

&lt;p&gt;The first step to creating the excel file is, to create the excel file. So we will write&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;workbook = xlsxwriter.Workbook(‘AllAboutPythonExcel.xlsx’)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This line will create an instance of workbook class, which represents the new excel file that we are creating. We have passed the name AllAboutPythonExcel as the excel’s name, you can name it whatever you like.&lt;/p&gt;

&lt;p&gt;Next, we will add a sheet to our newly created excel file. An excel can consist of one or more than one excel sheet, which contains the data. You can see the sheets at the bottom left of your screen when you open an excel in Microsoft excel.&lt;/p&gt;

&lt;p&gt;We are gonna write&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;worksheet = workbook.add_worksheet()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;If you guys want to name the worksheet, you can pass the name of the worksheet as a string onto the add_worksheet function, something like “firstSheet”&lt;/p&gt;

&lt;p&gt;Now in order to enter data in excel, we need data, so we will consider this list as our sample data to add in the excel,&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data = [
    {
        'name': "Edan Stein",
        'phone': "1-411-426-8735",
        'email': "facilisis.magna@aol.couk",
        'address': "594-6075 Elementum Ave",
        'country': "Belgium"
    },
    {
        'name': "Gretchen Whitfield",
        'phone': "(323) 253-9734",
        'email': "ipsum@protonmail.net",
        'address': "Ap #783-9102 Augue. Rd.",
        'country': "Netherlands"
    },
    {
        'name': "Violet Brooks",
        'phone': "1-389-367-4883",
        'email': "montes.nascetur.ridiculus@outlook.edu",
        'address': "Ap #814-4695 Odio. Street",
        'country': "India"
    },
    {
        'name': "Ethan Espinoza",
        'phone': "(428) 503-8130",
        'email': "vestibulum.lorem@yahoo.couk",
        'address': "3416 Suspendisse Rd.",
        'country': "Russian Federation"
    },
    {
        'name': "Martin Dunlap",
        'phone': "1-341-689-0165",
        'email': "natoque.penatibus@aol.couk",
        'address': "Ap #593-870 Rhoncus. Ave",
        'country': "Poland"
    }
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We have a variable by the name data, which is a list containing multiple dictionaries, each containing data of an individual, We have a name, phone, email address, and country information with us.&lt;/p&gt;

&lt;p&gt;Now one thing that you should understand is that the data in excel can be added using a for loop, so it will be better that the data you are gonna save in the excel, is present in the form of a collection, on which you can use a for loop, just like we have a list here.&lt;/p&gt;

&lt;p&gt;So we will start by adding headers for the data we are gonna write in excel. We will write&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;worksheet.write(0, 0, ‘#’)
worksheet.write(0, 1, ‘Name’)
worksheet.write(0, 2,  ‘Phone’)
worksheet.write(0, 3, ‘Email’)
worksheet.write(0, 4, ‘Address’)
worksheet.write(0, 5, ‘Country’)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Write function is used to insert data at a specific row and column in excel. The first argument is the row number, the second argument is the column number and the third argument is the text you want to enter.&lt;/p&gt;

&lt;p&gt;Since we are writing data at the top of the excel, the row number is zero, and the column number changes as we are writing data in the same row.&lt;/p&gt;

&lt;p&gt;Now we will quickly create a for loop that will go through each dictionary object present inside the data list. We will use the enumerate function to also get the index of the iteration, which will be used to add data onto each row. We will write&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for index, entry in enumerate(data):
    worksheet.write(index+1, 0, str(index))
    worksheet.write(index+1, 1, entry[‘name’])
    worksheet.write(index+1, 2, entry[‘phone’])
    worksheet.write(index+1, 3, entry[‘email’])
    worksheet.write(index+1, 4, entry[‘address’])
    worksheet.write(index+1, 5, entry[‘country’])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The for loop iterates through the entries in the data, and we use the worksheet.write function to keep adding data in excel. We are using index+1 as we have already added data to the excel at index 0.&lt;/p&gt;

&lt;p&gt;Now to close off the excel, we will write,&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;workbook.close()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Here is the complete code:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import xlsxwriter

data = [
    {
        'name': "Edan Stein",
        'phone': "1-411-426-8735",
        'email': "facilisis.magna@aol.couk",
        'address': "594-6075 Elementum Ave",
        'country': "Belgium"
    },
    {
        'name': "Gretchen Whitfield",
        'phone': "(323) 253-9734",
        'email': "ipsum@protonmail.net",
        'address': "Ap #783-9102 Augue. Rd.",
        'country': "Netherlands"
    },
    {
        'name': "Violet Brooks",
        'phone': "1-389-367-4883",
        'email': "montes.nascetur.ridiculus@outlook.edu",
        'address': "Ap #814-4695 Odio. Street",
        'country': "India"
    },
    {
        'name': "Ethan Espinoza",
        'phone': "(428) 503-8130",
        'email': "vestibulum.lorem@yahoo.couk",
        'address': "3416 Suspendisse Rd.",
        'country': "Russian Federation"
    },
    {
        'name': "Martin Dunlap",
        'phone': "1-341-689-0165",
        'email': "natoque.penatibus@aol.couk",
        'address': "Ap #593-870 Rhoncus. Ave",
        'country': "Poland"
    }
]

workbook = xlsxwriter.Workbook("AllAboutPythonExcel.xlsx")
worksheet = workbook.add_worksheet("firstSheet")

worksheet.write(0, 0, "#")
worksheet.write(0, 1, "Name")
worksheet.write(0, 2, "Phone")
worksheet.write(0, 3, "Email")
worksheet.write(0, 4, "Address")
worksheet.write(0, 5, "Country")

for index, entry in enumerate(data):
    worksheet.write(index+1, 0, str(index))
    worksheet.write(index+1, 1, entry["name"])
    worksheet.write(index+1, 2, entry["phone"])
    worksheet.write(index+1, 3, entry["email"])
    worksheet.write(index+1, 4, entry["address"])
    worksheet.write(index+1, 5, entry["country"])

workbook.close()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;If you run the script, you can see the script has created an excel file by the name AllAboutPythonExcel, the exact same name which we gave as an input to the script.&lt;/p&gt;

&lt;p&gt;If we open the excel file, we can see the name of the sheet as firstSheet, again the same name which we gave as an input, and we can see all our data inside the excel. &lt;/p&gt;

&lt;p&gt;If you want to make this code reusable, such that you can use it for your other python projects, you can create a function something like this.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def generate_excel(workbook_name: str, worksheet_name: str, headers_list: list, data: list):

    # Creating workbook
    workbook = xlsxwriter.Workbook(workbook_name)

    # Creating worksheet
    worksheet = workbook.add_worksheet(worksheet_name)

    # Adding headers
    for index, header in enumerate(headers_list):
        worksheet.write(0, index, str(header).capitalize())

    # Adding data
    for index1, entry in enumerate(data):
        for index2, header in enumerate(headers_list):
            worksheet.write(index1+1, index2, entry[header])

    # Close workbook
    workbook.close()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;You can pass values to this function and the function will automatically perform the above-explained operations and create the excel for you.&lt;/p&gt;

&lt;p&gt;As you can see here, the function requires parameters, the name of the excel, the name of the sheet, the list of keys contained in the data list, and finally the data list. The excel generated will look the same as it was created above. &lt;/p&gt;

&lt;p&gt;All the code used in this post is uploaded on GitHub:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--A9-wwsHG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/itsallaboutpython" rel="noopener noreferrer"&gt;
        itsallaboutpython
      &lt;/a&gt; / &lt;a href="https://github.com/itsallaboutpython/Excel-Creation" rel="noopener noreferrer"&gt;
        Excel-Creation
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;



&lt;p&gt;That’s all there is in this blog post, hope you liked the post, if you did don’t forget to follow.&lt;/p&gt;

&lt;p&gt;Also, you can watch a detailed video of the same topic on my YouTube Channel&lt;br&gt;
&lt;a href="https://youtube.com/AllAboutPython" rel="noopener noreferrer"&gt;YouTube Channel&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With this, it’s time for me to go, this is Vishesh Dvivedi, signing off&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Real-Time Chat Application In Python</title>
      <dc:creator>Vishesh Dvivedi</dc:creator>
      <pubDate>Tue, 07 Dec 2021 16:01:18 +0000</pubDate>
      <link>https://dev.to/visheshdvivedi/real-time-chat-application-in-python-3c00</link>
      <guid>https://dev.to/visheshdvivedi/real-time-chat-application-in-python-3c00</guid>
      <description>&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/cV-syT1fO2c"&gt;
&lt;/iframe&gt;
&lt;br&gt;
What's up Pythoneers ! This is Vishesh Dvivedi and in this blog post I am gonna show you how you can create a real-time chat application in python, using tkinter module and socket programming.&lt;/p&gt;

&lt;p&gt;This blog will discuss about socket programming, tkinter module and how you can integrate them both.&lt;/p&gt;

&lt;h2&gt;
  
  
  About the application
&lt;/h2&gt;

&lt;p&gt;The repository of this application consists of two python files, server.py and client.py. server.py is the script that runs the server, which all the clients will use to communicate to each other. And client.py will be used by the client to connect to server and send messages to other clients.&lt;/p&gt;

&lt;p&gt;So we will start off by server.py script&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating server.py
&lt;/h2&gt;

&lt;p&gt;First off, we will import all the required modules of server.py&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import socket
import threading
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We would need socket module to communicate with clients and threading module to create a thread that would keep listening for messages from clients.&lt;/p&gt;

&lt;p&gt;Next we will set up some variables&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HOST = '127.0.0.1'
PORT = 1234 
LISTENER_LIMIT = 5
active_clients = []
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;HOST and PORT here determines the host and port at which the server will run, LISTENER_LIMIT stores the amount of clients that will be able to connect to a server at a time. And finally, active_clients will store all the users that will be connected to the server at any instance&lt;/p&gt;

&lt;p&gt;Next we will create the listen_for_messages function&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def listen_for_messages(client, username):

    while 1:

        message = client.recv(2048).decode('utf-8')
        if message != '':

            final_msg = username + '~' + message
            send_messages_to_all(final_msg)

        else:
            print(f"The message send from client {username} is 
empty")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This function will keep listening for messages from the connected clients. In case if it received a message, it will call the send_message_to_all function to send the received message to all currently connected clients.&lt;/p&gt;

&lt;p&gt;Next we create the send_message_to_client function&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def send_message_to_client(client, message):

    client.sendall(message.encode())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This function is used to send message to a single client&lt;/p&gt;

&lt;p&gt;Next we create the send_message_to_all function&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def send_messages_to_all(message):

    for user in active_clients:

        send_message_to_client(user[1], message)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This function will send a message to all connected clients by calling the send_message function for each connected client.&lt;/p&gt;

&lt;p&gt;Next we create the client_handler function&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def client_handler(client):

    # Server will listen for client message that will
    # Contain the username
    while 1:

        username = client.recv(2048).decode('utf-8')
        if username != '':
            active_clients.append((username, client))
            prompt_message = "SERVER~" + f"{username} added to 
the chat"
            send_messages_to_all(prompt_message)
            break
        else:
            print("Client username is empty")

    threading.Thread(target=listen_for_messages, args=(client, 
username, )).start()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This function will use the client object (explained later in this blog) which we get when we connect to a client, to get username from a client, add the client to the list of active clients, and start a listener thread which will keep listening for new messages from the client.&lt;br&gt;
Note: This function is also executed as a thread, for each new connected client.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def main():

    server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)


    try:
        server.bind((HOST, PORT))
        print(f"Running the server on {HOST} {PORT}")
    except:
        print(f"Unable to bind to host {HOST} and port 
{PORT}")

    server.listen(LISTENER_LIMIT)

    while 1:

        client, address = server.accept()
    print(f"Successfully connected to client {address[0]} {address[1]}")

    threading.Thread(target=client_handler, args=(client, )).start()


if __name__ == '__main__':
    main()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And finally we have the main function, which performs the work of: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Creating a socket (that acts as the server)&lt;/li&gt;
&lt;li&gt;Binding IP and Port to the server&lt;/li&gt;
&lt;li&gt;Setting up listener limit&lt;/li&gt;
&lt;li&gt;Accept any upcoming connection from clients&lt;/li&gt;
&lt;li&gt;Calling the client handler for any new connected client&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That's all for the server side code, The server side code is a bit long to explain in a single blog, so I have created this playlist on YouTube, where I explain all the code, both server and client side code. So do check out this playlist to understand the client side code as well.&lt;/p&gt;

&lt;p&gt;Link to playlist: &lt;a href="https://www.youtube.com/playlist?list=PLIw91yhFTTdJ2CDjOptoF-ddXbw7wmet-" rel="noopener noreferrer"&gt;How To Create A Real-Time Chat App In Python Using Socket Programming&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Get Colored Console Output In Python Using Colorama</title>
      <dc:creator>Vishesh Dvivedi</dc:creator>
      <pubDate>Mon, 22 Nov 2021 06:25:36 +0000</pubDate>
      <link>https://dev.to/visheshdvivedi/get-colored-console-output-in-python-using-colorama-4gci</link>
      <guid>https://dev.to/visheshdvivedi/get-colored-console-output-in-python-using-colorama-4gci</guid>
      <description>&lt;p&gt;In this blog I am gonna talk about a python module that can make your console based applications look much better than they normally look, the colorama module.&lt;/p&gt;

&lt;p&gt;Here's how a normal console application looks without using colorama.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-OI92mMfspec/YNn-I-V7dQI/AAAAAAAAAYo/ecepCARIsNMd4L6xsemnjOEfsaJPthjdgCLcBGAsYHQ/s1202/coloring_script_using_colorama.PNG" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-OI92mMfspec%2FYNn-I-V7dQI%2FAAAAAAAAAYo%2FecepCARIsNMd4L6xsemnjOEfsaJPthjdgCLcBGAsYHQ%2Fw640-h315%2Fcoloring_script_using_colorama.PNG" title="coloring using colorama" alt="coloring using&amp;lt;br&amp;gt;
colorama"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And here's how the same script would look with some color effects.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-1vQpuFKYtr4/YNqj1JgXODI/AAAAAAAAAY8/uwCiHwc2mFUretP0MhTazsDzQyd-NFfOgCLcBGAsYHQ/s1236/colorama_module.PNG" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-1vQpuFKYtr4%2FYNqj1JgXODI%2FAAAAAAAAAY8%2FuwCiHwc2mFUretP0MhTazsDzQyd-NFfOgCLcBGAsYHQ%2Fw640-h300%2Fcolorama_module.PNG" title="how_to_get_colored_output" alt="how\_to\_get\_colored\_output"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Isn't that beautiful !!!&lt;/p&gt;

&lt;p&gt;All of this was possible due to colorama module. And we are gonna learn how we can use this module in python.&lt;/p&gt;

&lt;h2&gt;
  
  
  About The Module
&lt;/h2&gt;

&lt;p&gt;Colorama is a python module that is used to display colored output in console. It can change both, foreground and background color of any text which is displayed in the console.&lt;/p&gt;

&lt;p&gt;The link to its github repository is this:&lt;br&gt;
&lt;a href="https://github.com/tartley/colorama" rel="noopener noreferrer"&gt;colorama&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-erQzkaJRr5k/YNrcU4vnvNI/AAAAAAAAAZE/xSvIC8FHI6AhGeJgMMYTtUO51lFQ4WhUQCLcBGAsYHQ/s1894/colorama_github.PNG" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-erQzkaJRr5k%2FYNrcU4vnvNI%2FAAAAAAAAAZE%2FxSvIC8FHI6AhGeJgMMYTtUO51lFQ4WhUQCLcBGAsYHQ%2Fw640-h294%2Fcolorama_github.PNG" title="colorama github" alt="colorama&amp;lt;br&amp;gt;
github"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started With Colorama
&lt;/h2&gt;

&lt;p&gt;First you need to download and install colorama. Just open your command prompt and type the following:&lt;/p&gt;

&lt;p&gt;For Windows:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install colorama
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;For Linux:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo pip3 install colorama
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This will automatically download and install colorama in your system.&lt;/p&gt;

&lt;p&gt;(Note: you should have pip installed in your system for this to work, If it is not, check out &lt;a href="https://phoenixnap.com/kb/install-pip-windows" rel="noopener noreferrer"&gt;this blog&lt;/a&gt; and setup your pip)&lt;/p&gt;

&lt;p&gt;Once your colorama is installed, you can import colorama in any of your python script and use it. Now let's learn how to use it within our scripts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using colorama
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Initializing colorama
&lt;/h3&gt;

&lt;p&gt;First we have to initialize colorama by running the init method, like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from colorama import init
init()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;On Windows, calling &lt;code&gt;init()&lt;/code&gt; will filter ANSI escape sequences out of any text sent to &lt;code&gt;stdout&lt;/code&gt; or &lt;code&gt;stderr&lt;/code&gt;, and replace them with equivalent Win32 calls.&lt;/p&gt;

&lt;p&gt;On other platforms, it's not of much use. So don't forget to call this function is your script runs on Windows.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Colored Output
&lt;/h4&gt;

&lt;p&gt;It's time we write our first colored output on the screen, like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from colorama import init, Fore, Back, Style

init()
print(" Normal white color")
print(Fore.RED + " Letters will be in red ")
print(Back.GREEN + " Background will be green " + 
Style.RESET\_ALL)
print(Style.DIM + Fore.RED + Back.GREEN + " And style will be 
dim " + Style.RESET\_ALL)
print(" And everything is back to normal")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The output would look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-3krstzmJtdQ/YNrj-STHE_I/AAAAAAAAAZM/2kte2KCh-qgZtobxY3Xxeiyop1ViLmxLgCLcBGAsYHQ/s625/colorama_output.PNG" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-3krstzmJtdQ%2FYNrj-STHE_I%2FAAAAAAAAAZM%2F2kte2KCh-qgZtobxY3Xxeiyop1ViLmxLgCLcBGAsYHQ%2Fw640-h252%2Fcolorama_output.PNG" title="colorama output" alt="colorama&amp;lt;br&amp;gt;
output"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you might understand, you can change the foreground letter color using the Fore class and selecting the correct color constant you want to use. You can change background color using Back class and change style of letters using Style class.&lt;/p&gt;

&lt;p&gt;Here are the possible foreground, background and style class.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 {style="background-color: #f9f9f9; border: 1px solid rgb(211, 211, 211); box-sizing: inherit; color: #6c6c6c; font-family: "Source Code Pro", monospace; font-size: 0.85rem; margin-bottom: 0px; margin-top: 30px; overflow: auto; padding: 15px;"}
Fore: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET.
Back: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET.
Style: DIM, NORMAL, BRIGHT, RESET_ALL


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

&lt;/div&gt;

&lt;p&gt;Note: The color effects that you will place will remain consistent, unless you call deinit() function or  mention Fore.RESET, Back.RESET or Style.RESET_ALL.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Using termcolor
&lt;/h4&gt;

&lt;p&gt;You can also use termcolor (in Windows) to color a specific portion of the console output&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from colorama import init
from termcolor import colored

init()

print(colored("This is in red color", "red"))
print(colored("This is in yellow color", "yellow"))
print(colored("This is in blue color", "blue"))
print(colored("This is in cyan color", "cyan"))
print(colored("This is in green color", "green"))
print(colored("This is in magenta color", "magenta"))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-rCP5iAFHFR0/YNsDr8McPzI/AAAAAAAAAZU/XkPiYRLcYCAUBAseE3PstVSHMR6R_mwOwCLcBGAsYHQ/s305/colorama_colors.PNG" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-rCP5iAFHFR0%2FYNsDr8McPzI%2FAAAAAAAAAZU%2FXkPiYRLcYCAUBAseE3PstVSHMR6R_mwOwCLcBGAsYHQ%2Fw640-h424%2Fcolorama_colors.PNG" title="colorama colors" alt="colorama&amp;lt;br&amp;gt;
colors"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;just import colored function from termcolor and use it as following:&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print( colored( "string to color",  "color name" ) )&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Conclusion&lt;br&gt;
&lt;/h2&gt;

&lt;p&gt;Overall this is a very awesome module and I bet you should definitely try using this module within your scripts, to give it a more professional look and feel.&lt;/p&gt;

&lt;p&gt;Hope this blog helped you all :)&lt;/p&gt;

&lt;p&gt;You can follow me on&lt;br&gt;
&lt;a href="https://www.youtube.com/channel/UCggZvARaczWC4wc4E6f330w?sub_confirmation=1" rel="noopener noreferrer"&gt;YouTube&lt;/a&gt;,&lt;br&gt;
&lt;a href="https://www.instagram.com/itsallaboutpython" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt;,&lt;br&gt;
&lt;a href="https://www.youtube.com/redirect?event=channel_banner&amp;amp;redir_token=QUFFLUhqazNFMkhoS05EZDBGYkV4bjB3Q2VUelp5M3JlZ3xBQ3Jtc0trVHdHUVMxY0RHYWtyRVRFbXBKZFBnWFV1VkVUazZVOW9zaE91Zi1qN3BkSFNOQjhlQXRhUE1JVkdfVGJtU2c5U3BXdGViZUhpRnNtbTdZeElQX2o5WGdtN0wxTm1fcjJOQ0NhMUVmWF9adUVJVThFVQ&amp;amp;q=https%3A%2F%2Fwww.linkedin.com%2Fin%2Fvishesh-dvivedi-07a82a20b%2F" rel="noopener noreferrer"&gt;Linkedin&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Send Bulk WhatsApp Messages In Python | Automate WhatsApp Using Python</title>
      <dc:creator>Vishesh Dvivedi</dc:creator>
      <pubDate>Wed, 03 Nov 2021 04:02:59 +0000</pubDate>
      <link>https://dev.to/visheshdvivedi/send-bulk-whatsapp-messages-in-python-automate-whatsapp-using-python-ipo</link>
      <guid>https://dev.to/visheshdvivedi/send-bulk-whatsapp-messages-in-python-automate-whatsapp-using-python-ipo</guid>
      <description>&lt;p&gt;What’s up pythoneers, I’m back again with another blog on my channel All About Python. If you have been following my channel, you would know that I have started a python automation playlist where I attempt to automate various well-known apps and APIs using python. And three such blog have been performing really well, especially the Instagram automation blog . So I decided to, this time, make a blog on automating WhatsApp messaging with python, and next, I will make a blog on automating Twitter. So&lt;br&gt;
don’t forget to subscribe to my channel and click on the bell icon so that you are notified whenever I upload a new blog &lt;/p&gt;

&lt;p&gt;This blog will focus on creating a python script that will read the phone numbers, names, and messages from excel and then send bulk WhatsApp messages to the respective phone numbers. One catch here is that the phone number should be saved on the device which is being used to send the WhatsApp message.&lt;/p&gt;

&lt;p&gt;In this blog , I am gonna discuss, about&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; WhatsApp Web and how this script uses it&lt;/li&gt;
&lt;li&gt; Function wise analysis of the script&lt;/li&gt;
&lt;li&gt; Quick demo explaining the working of the script&lt;/li&gt;
&lt;li&gt; An alternative way to create the script.&lt;/li&gt;
&lt;li&gt; Some ideas for modifications and improvements within the script&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let’s start with WhatsApp Web:&lt;/p&gt;

&lt;h2&gt;
  
  
  WhatsApp Web
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-cy4ERPLonpo/YPUrMaLXISI/AAAAAAAAAbA/6VpHEspmqWwkq1WSF0lrLPvC3x9fK9ULQCLcBGAsYHQ/s1606/WhatsApp%2BWeb.PNG" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-cy4ERPLonpo%2FYPUrMaLXISI%2FAAAAAAAAAbA%2F6VpHEspmqWwkq1WSF0lrLPvC3x9fK9ULQCLcBGAsYHQ%2Fw640-h288%2FWhatsApp%252BWeb.PNG" title="Send Bulk WhatsApp Messages In Python - WhatsApp Web" alt="Send Bulk WhatsApp Messages In Python - WhatsApp Web"&gt;&lt;/a&gt;&lt;br&gt;
  WhatsApp Web&lt;/p&gt;

&lt;p&gt;WhatsApp Web is a feature of WhatsApp that lets you operate your&lt;br&gt;
WhatsApp from your laptop or desktop browser. The steps to use WhatsApp web are pretty simple, just open a chrome browser within your computer and open site web.whatsapp.com, next scan the appearing QR code using your phone, and your WhatsApp will appear on the chrome browser. Here you can message anyone or any group or can see WhatsApp status.&lt;/p&gt;

&lt;p&gt;This script uses the selenium library to automate the browser and send bulk messages to multiple contacts within WhatsApp.&lt;/p&gt;

&lt;p&gt;With the basic working of the script understood, let’s move on to&lt;br&gt;
functional-wise analysis of the script.&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="n"&gt;art&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;platform&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;colorama&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;init&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Fore&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;termcolor&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;colored&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pandas&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;selenium&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;webdriver&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;selenium.webdriver.support&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;expected_conditions&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;EC&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;selenium.webdriver.common.by&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;By&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;selenium.webdriver.support.ui&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;WebDriverWait&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;selenium.webdriver.common.keys&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Keys&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;selenium.webdriver.common.action_chains&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;ActionChains&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;The script starts by importing all the required modules. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  The art module is used to create and display ASCII art for the
script. If you wanna know how it works, you can check out &lt;a href="https://itsallaboutpython.blogspot.com/2021/05/how-to-create-beautiful-ascii-art-in.html" rel="noopener noreferrer"&gt;this
blog&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;  Time is used to halt program execution for some seconds using
time.sleep()&lt;/li&gt;
&lt;li&gt;  OS is used to run operating system commands within the script.&lt;/li&gt;
&lt;li&gt;  The platform module is used to identify the operating system.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Together, os and platform are used to clear the screen, as you can see&lt;br&gt;
here.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Colorama and termcolor are used to display colored console output of
the script. If you wanna know more about them, you can check out
&lt;a href="https://itsallaboutpython.blogspot.com/2021/06/get-colored-console-output-in-python.html" rel="noopener noreferrer"&gt;this
blog&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;  Pandas is used to read data from the excel file.&lt;/li&gt;
&lt;li&gt;  Datetime is used to find the current date and time.&lt;/li&gt;
&lt;li&gt;  And finally, we have selenium. All these import statements you see
here are just importing&lt;/li&gt;
&lt;li&gt;  Required classes and functions from selenium.&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;FILE_LOC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;data.xlsx&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;SRNO&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;SRNO&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="n"&gt;NAME&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Name&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="n"&gt;PHONENUMBER&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Phone Number&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="n"&gt;MESSAGE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Message&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="n"&gt;REPLACENAME&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;{{name}}&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="n"&gt;URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;https://web.whatsapp.com/&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="n"&gt;WAITER_ELEMENT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;landing-title _3-XoE&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;PHONE_NUMER_INPUT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;//*[@id=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;side&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;]/div[1]/div/label/div/div[2]&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;PERSON_DIV&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;//*[@id=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;pane-side&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;]/div[1]/div/div/div[1]/div/div/div[1]/div/div/img&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;MESSAGE_INPUT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;//*[@id=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;main&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;]/footer/div[1]/div[2]/div/div[1]/div/div[2]&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;SEND_BUTTON&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;//*[@id=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;main&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;]/footer/div[1]/div[2]/div/div[2]/button&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;Next, we have all the constants used within the script, including the URL, excel field names, button, and textbox xpaths, etc. Just a quick idea, xpaths are basically like search filters that are used to identify a certain element or a group of elements within an HTML page.&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;driver&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;webdriver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Chrome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;chromedriver.exe&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;implicitly_wait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;waiter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;WebDriverWait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;Next, we have started and configured the driver and waiter of our&lt;br&gt;
script.&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;printData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&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="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;INFO&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="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;colored&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;strftime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;%H:%M:%S&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;cyan&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;][&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;colored&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;INFO&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;green&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;  &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;] &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;WARNING&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="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;colored&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;strftime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;%H:%M:%S&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;cyan&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;][&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;colored&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;WARNING&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;yellow&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;  &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;] &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ERROR&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="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;colored&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;strftime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;%H:%M:%S&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;cyan&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;][&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;colored&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ERROR&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;red&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;  &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;] &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;Now we have the first function of our script, the printData function.&lt;/p&gt;

&lt;p&gt;This function requires two arguments, message, and type. This function is used to print colored data on the console, either informational, warning or error.The function simply checks what is the type passed onto it and accordingly prints the message on the console.&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;read_data_from_excel&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;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read_excel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;FILE_LOC&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nf"&gt;printData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Retrieving data from excel&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;INFO&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;printData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Excel &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;data.xlsx&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; not found&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ERROR&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;printData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Found {0} messages to be send&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;INFO&lt;/span&gt;&lt;span class="sh"&gt;'&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="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;+&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;PHONENUMBER&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]):&lt;/span&gt;
            &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;+91&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;PHONENUMBER&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;i&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="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;PHONENUMBER&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="n"&gt;output&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;SrNo&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;SRNO&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
            &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Name&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;NAME&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
            &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;PhoneNumber&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Message&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;MESSAGE&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;REPLACENAME&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;NAME&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;output&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;Next, we have the read_data_from_excel() function that reads all the messages to be sent from the data.xlsx file. The function uses the pandas' library to read the data from excel and store the excel entries in a data list within the script.&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;send_whatsapp_message&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;global&lt;/span&gt; &lt;span class="n"&gt;driver&lt;/span&gt;
    &lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;printData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Loading site...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;INFO&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;waiter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;until&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;EC&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;title_is&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;WhatsApp&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="nf"&gt;printData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Site loaded successfully...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;INFO&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;printData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Waiting for user to log in using WhatsApp Web&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;INFO&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;waitCounter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;while&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;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;waiter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;until&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;EC&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;presence_of_element_located&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;By&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;XPATH&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;//canvas[@aria-label=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Scan me!&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&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;waitCounter&lt;/span&gt;&lt;span class="o"&gt;+=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;waitCounter&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nf"&gt;printData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Waiting for user to log in...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;WARNING&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;except&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;printData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Logged in to WhatsApp&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;INFO&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;break&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;entry&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_element_by_xpath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;PHONE_NUMER_INPUT&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;send_keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;PhoneNumber&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt;
        &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&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="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_element_by_xpath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;PHONE_NUMER_INPUT&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;send_keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Keys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ENTER&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&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="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_element_by_xpath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MESSAGE_INPUT&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;send_keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Message&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt;
        &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&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="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_element_by_xpath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SEND_BUTTON&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;click&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&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="nf"&gt;printData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Successfully send message to {0}, name: {1}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;PhoneNumber&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Name&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])),&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;INFO&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;Next, we have the most important function of the script, which is the send_whatsapp_message() function. This function is responsible for reading contacts from the data list and one-by-one send WhatsApp messages to each one of them. &lt;/p&gt;

&lt;p&gt;The function starts by loading the WhatsApp website and waiting for it to load. Once the site is loaded, the script waits for the user to scan the QR code and log in to the site. Once the user is logged in, the script searches for each contact, opens its chat, types the message, and sends it.&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;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Initialize colorama
&lt;/span&gt;    &lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;# Clear the screen
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;platform&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;system&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Windows&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;system&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;cls&lt;/span&gt;&lt;span class="sh"&gt;'&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="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;system&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;clear&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# Display ASCII art
&lt;/span&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;art&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;text2art&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;WhatsApp Python&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="n"&gt;Fore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CYAN&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;Created By:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;Fore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RESET&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; Vishesh Dvivedi [All About Python]&lt;/span&gt;&lt;span class="se"&gt;\n&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="n"&gt;Fore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;YELLOW&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;GitHub: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;Fore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RESET&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;   visheshdvivedi&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="n"&gt;Fore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;YELLOW&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Youtube:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;Fore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RESET&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;   All About Python&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="n"&gt;Fore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;YELLOW&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Instagram:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;Fore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RESET&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; @itsallaboutpython&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="n"&gt;Fore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;YELLOW&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Blog Site:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;Fore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RESET&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; itsallaboutpython.blogspot.com&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


    &lt;span class="c1"&gt;# Read data from 'data.xlsx' file
&lt;/span&gt;    &lt;span class="nf"&gt;read_data_from_excel&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;# Send whatsapp message 
&lt;/span&gt;    &lt;span class="nf"&gt;send_whatsapp_message&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;# Close chromedriver
&lt;/span&gt;    &lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;And finally, we have the main function. In case you are unclear with the use of if __name__ == ‘__main__’, then you can check out a blog on my channel dedicated to this topic.&lt;/p&gt;

&lt;p&gt;Within the main function, first, init() is used to initialize Colorama. Next, I have used a code snippet to execute an OS command to clear the screen, based on the operating system used. Next, the art module is used to display the ASCII are for the script, and below that, you will find contact information about me, in case you want to contact me.&lt;/p&gt;

&lt;p&gt;And finally, we call the read_data_from_excel() and&lt;br&gt;
send_whatsapp_message() function which performs the rest of the&lt;br&gt;
functions, as we discussed before. And then we end the script by closing the driver.&lt;/p&gt;

&lt;p&gt;That’s all there is in this script. Here is the full code.&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="n"&gt;art&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;platform&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;colorama&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;init&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Fore&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;termcolor&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;colored&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pandas&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;selenium&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;webdriver&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;selenium.webdriver.support&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;expected_conditions&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;EC&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;selenium.webdriver.common.by&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;By&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;selenium.webdriver.support.ui&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;WebDriverWait&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;selenium.webdriver.common.keys&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Keys&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;selenium.webdriver.common.action_chains&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;ActionChains&lt;/span&gt;

&lt;span class="n"&gt;FILE_LOC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;data.xlsx&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;SRNO&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;SRNO&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="n"&gt;NAME&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Name&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="n"&gt;PHONENUMBER&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Phone Number&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="n"&gt;MESSAGE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Message&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="n"&gt;REPLACENAME&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;{{name}}&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="n"&gt;URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;https://web.whatsapp.com/&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="n"&gt;WAITER_ELEMENT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;landing-title _3-XoE&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;PHONE_NUMER_INPUT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;//*[@id=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;side&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;]/div[1]/div/label/div/div[2]&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;PERSON_DIV&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;//*[@id=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;pane-side&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;]/div[1]/div/div/div[1]/div/div/div[1]/div/div/img&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;MESSAGE_INPUT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;//*[@id=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;main&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;]/footer/div[1]/div[2]/div/div[1]/div/div[2]&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;SEND_BUTTON&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;//*[@id=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;main&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;]/footer/div[1]/div[2]/div/div[2]/button&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="n"&gt;driver&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;webdriver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Chrome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;chromedriver.exe&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;implicitly_wait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;waiter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;WebDriverWait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;printData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&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="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;INFO&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="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;colored&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;strftime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;%H:%M:%S&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;cyan&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;][&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;colored&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;INFO&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;green&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;  &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;] &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;WARNING&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="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;colored&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;strftime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;%H:%M:%S&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;cyan&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;][&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;colored&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;WARNING&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;yellow&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;  &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;] &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ERROR&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="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;colored&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;strftime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;%H:%M:%S&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;cyan&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;][&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;colored&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ERROR&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;red&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;  &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;] &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;read_data_from_excel&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;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read_excel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;FILE_LOC&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nf"&gt;printData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Retrieving data from excel&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;INFO&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;printData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Excel &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;data.xlsx&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; not found&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ERROR&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;printData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Found {0} messages to be send&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;INFO&lt;/span&gt;&lt;span class="sh"&gt;'&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="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;+&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;PHONENUMBER&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]):&lt;/span&gt;
            &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;+91&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;PHONENUMBER&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;i&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="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;PHONENUMBER&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="n"&gt;output&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;SrNo&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;SRNO&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
            &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Name&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;NAME&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
            &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;PhoneNumber&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Message&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;MESSAGE&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;REPLACENAME&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;NAME&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;output&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;send_whatsapp_message&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;global&lt;/span&gt; &lt;span class="n"&gt;driver&lt;/span&gt;
    &lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;printData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Loading site...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;INFO&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;waiter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;until&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;EC&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;title_is&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;WhatsApp&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="nf"&gt;printData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Site loaded successfully...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;INFO&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;printData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Waiting for user to log in using WhatsApp Web&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;INFO&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;waitCounter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;while&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;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;waiter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;until&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;EC&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;presence_of_element_located&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;By&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;XPATH&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;//canvas[@aria-label=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Scan me!&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&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;waitCounter&lt;/span&gt;&lt;span class="o"&gt;+=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;waitCounter&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nf"&gt;printData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Waiting for user to log in...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;WARNING&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;except&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;printData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Logged in to WhatsApp&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;INFO&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;break&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;entry&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_element_by_xpath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;PHONE_NUMER_INPUT&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;send_keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;PhoneNumber&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt;
        &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&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="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_element_by_xpath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;PHONE_NUMER_INPUT&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;send_keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Keys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ENTER&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&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="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_element_by_xpath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MESSAGE_INPUT&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;send_keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Message&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt;
        &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&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="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_element_by_xpath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SEND_BUTTON&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;click&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&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="nf"&gt;printData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Successfully send message to {0}, name: {1}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;PhoneNumber&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Name&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])),&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;INFO&lt;/span&gt;&lt;span class="sh"&gt;'&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;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Initialize colorama
&lt;/span&gt;    &lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;# Clear the screen
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;platform&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;system&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Windows&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;system&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;cls&lt;/span&gt;&lt;span class="sh"&gt;'&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="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;system&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;clear&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# Display ASCII art
&lt;/span&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;art&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;text2art&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;WhatsApp Python&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="n"&gt;Fore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CYAN&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;Created By:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;Fore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RESET&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; Vishesh Dvivedi [All About Python]&lt;/span&gt;&lt;span class="se"&gt;\n&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="n"&gt;Fore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;YELLOW&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;GitHub: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;Fore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RESET&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;   visheshdvivedi&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="n"&gt;Fore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;YELLOW&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Youtube:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;Fore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RESET&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;   All About Python&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="n"&gt;Fore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;YELLOW&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Instagram:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;Fore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RESET&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; @itsallaboutpython&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="n"&gt;Fore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;YELLOW&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Blog Site:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;Fore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RESET&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; itsallaboutpython.blogspot.com&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


    &lt;span class="c1"&gt;# Read data from 'data.xlsx' file
&lt;/span&gt;    &lt;span class="nf"&gt;read_data_from_excel&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;# Send whatsapp message 
&lt;/span&gt;    &lt;span class="nf"&gt;send_whatsapp_message&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;# Close chromedriver
&lt;/span&gt;    &lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;Let’s go through a quick demo to see how it works.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-NSf1rbCsaBM/YPVl_NqDjAI/AAAAAAAAAcA/5syjzhGzPMMpDpmYIEPHCb7sQTcmy_-1wCLcBGAsYHQ/s1098/console%2Boutput.PNG" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-NSf1rbCsaBM%2FYPVl_NqDjAI%2FAAAAAAAAAcA%2F5syjzhGzPMMpDpmYIEPHCb7sQTcmy_-1wCLcBGAsYHQ%2Fw640-h308%2Fconsole%252Boutput.PNG" title="WhatsApp Automation Python" alt="WhatsApp Automation Python"&gt;&lt;/a&gt;&lt;br&gt;
  WhatsApp Automation Python&lt;/p&gt;

&lt;p&gt;This is how the script looks like when it is executed. I have the chrome browser right here and the web.whatsapp.com site is opened right here. Now I will scan the QR code using WhatsApp and my WhatsApp will appear in front of my screen.&lt;/p&gt;

&lt;p&gt;After this, the script will, one by one, search for contacts from all the contacts, open their chat, and then it will automatically message them. If the message is of multiple lines, then a message will be sent for each line.&lt;/p&gt;

&lt;p&gt;I hope this cleared your doubts about this script. In case you still have any doubts left, you can mention it down in the comments below.&lt;/p&gt;

&lt;p&gt;All of this code may be a bit confusing for some of you, and you may wonder whether there is an alternative and easy way to make this code. There is!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-AX7Y_tuKztA/YPVmXSqFiXI/AAAAAAAAAcI/fHIi7lL1DHISFjbD32dYgI6ooIOOFOEqwCLcBGAsYHQ/s1894/pywhatkit.PNG" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-AX7Y_tuKztA%2FYPVmXSqFiXI%2FAAAAAAAAAcI%2FfHIi7lL1DHISFjbD32dYgI6ooIOOFOEqwCLcBGAsYHQ%2Fw640-h292%2Fpywhatkit.PNG" title="pywhatkit" alt="pywhatkit"&gt;&lt;/a&gt;&lt;br&gt;
  pywhatkit&lt;/p&gt;

&lt;p&gt;There is a module by the name pywhatkit, which contains a method that allows you to send custom WhatsApp messages. If you guys want, I will make a separate blog explaining pywhatkit to you all.&lt;/p&gt;

&lt;p&gt;Now comes the last topic of this blog , Ideas for modifications and improvements in the blog . I had created this script just to explain to you all how you can create this script. However, there are still a ton of modifications and improvements that can be done within the script. &lt;/p&gt;

&lt;p&gt;For example, you can add a time system to it which will allow you to send WhatsApp messages at a specific time and day. For that, you’ll have to add a while loop before calling the send_whatsapp_message. The loop will check after every minute the current time. If it matches the time to send the WhatsApp message, the loop will break and the message will be sent.&lt;/p&gt;

&lt;p&gt;Similarly, you can create a constant for wait time and that constant can be used to find out how much wait should be done while sending the message, as WhatsApp web may block this python script in some cases.&lt;/p&gt;

&lt;p&gt;That’s all in this blog guys, hope you liked my blog . If you did, don’t forget to subscribe to my channel to check for various other automation scripts that I have created for Instagram and YouTube.  &lt;/p&gt;

&lt;p&gt;With this, it's time for me to go, this is Vishesh Dvivedi, signing off.&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Simple Python Projects for Beginners With Source Code</title>
      <dc:creator>Vishesh Dvivedi</dc:creator>
      <pubDate>Tue, 02 Nov 2021 04:41:42 +0000</pubDate>
      <link>https://dev.to/visheshdvivedi/simple-python-projects-for-beginners-with-source-code-4nb8</link>
      <guid>https://dev.to/visheshdvivedi/simple-python-projects-for-beginners-with-source-code-4nb8</guid>
      <description>&lt;p&gt;I believe that the best way to master any programming language is to&lt;br&gt;
create real-life projects using that language. The same is the case with&lt;br&gt;
the python programming language. If you are a beginner python&lt;br&gt;
programmer, and you want to master the python programming language, then it's really important that you start creating real-life projects using python language.&lt;/p&gt;

&lt;p&gt;Now it can be a bit difficult for beginner programmers to find projects&lt;br&gt;
that are easy for them to build along with the source code for research&lt;br&gt;
and analysis as to how the project works. So I have created a list of&lt;br&gt;
the top 10 easy python project ideas for beginners along with their&lt;br&gt;
source code. &lt;/p&gt;

&lt;p&gt;As you will progress through this post, the project difficulty level&lt;br&gt;
will keep going higher. As a beginner programmer, you should be able to&lt;br&gt;
create all these projects by yourself, as you go through your&lt;br&gt;
programming journey.&lt;/p&gt;

&lt;p&gt;If you liked my post, don’t forget to check out other posts on my blog&lt;br&gt;
site.&lt;/p&gt;

&lt;p&gt;You can also check out my YouTube channel, where I already have a video&lt;br&gt;
on this topic.&lt;/p&gt;

&lt;p&gt;So let’s start with our list&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Calculator
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-z90ZW7j9mNU/YRqt9jaOhmI/AAAAAAAAAcs/x1gInDZTlcgY4Oh4PSpU5sJK0Vi_DCRCgCLcBGAsYHQ/s1920/simple%2Bpython%2Bprojects%2Bfor%2Bbeginners%2Bwith%2Bsource%2Bcode%2B-%2Bcalculator.jpg" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-z90ZW7j9mNU%2FYRqt9jaOhmI%2FAAAAAAAAAcs%2Fx1gInDZTlcgY4Oh4PSpU5sJK0Vi_DCRCgCLcBGAsYHQ%2Fw640-h378%2Fsimple%252Bpython%252Bprojects%252Bfor%252Bbeginners%252Bwith%252Bsource%252Bcode%252B-%252Bcalculator.jpg" title="simple python projects for beginners with source code - calculator.jpg" alt="simple python projects for beginners with source code - calculator.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The calculator is probably one of the most common project ideas that you will see in many youtube videos. And the reason for this is that it is&lt;br&gt;
very easy to make and it will clear your basic concepts regarding&lt;br&gt;
if-else statements and while loop.&lt;/p&gt;

&lt;p&gt;The calculator will start by asking what the user wants to do, like:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Addition&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Subtraction&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Multiplication&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Division, and&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Exit&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Based on the option, the script will either add, subtract, multiply or&lt;br&gt;
divide the numbers that the user entered. Once the operation is&lt;br&gt;
complete, the script will again ask the user its choice. If the user&lt;br&gt;
chooses to exit, the program will stop.&lt;br&gt;
You can find this project source code&lt;br&gt;
&lt;a href="https://github.com/visheshdvivedi/Top-10-Easy-Python-Project-Ideas-For-Beginners/blob/main/calculator.py" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Dice Rolling Simulator
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-lwn5gSZUl9E/YRquR_cv9WI/AAAAAAAAAc0/8hakSZ0M-X45CkXWF6kvzqZmj34KWI_wgCLcBGAsYHQ/s1920/simple%2Bpython%2Bprojects%2Bfor%2Bbeginners%2Bwith%2Bsource%2Bcode%2B-%2Bdice%2Brolling%2Bsimulator.jpg" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-lwn5gSZUl9E%2FYRquR_cv9WI%2FAAAAAAAAAc0%2F8hakSZ0M-X45CkXWF6kvzqZmj34KWI_wgCLcBGAsYHQ%2Fw640-h336%2Fsimple%252Bpython%252Bprojects%252Bfor%252Bbeginners%252Bwith%252Bsource%252Bcode%252B-%252Bdice%252Brolling%252Bsimulator.jpg" title="simple python projects for beginners with source code - dice rolling simulator" alt="simple python projects for beginners with source code - dice rolling&amp;lt;br&amp;gt;
simulator"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This project is, again, an easy one, but at the same time, a very&lt;br&gt;
crucial one as it will introduce beginner python programmers to the&lt;br&gt;
random library. Random library is used to generate pseudo-random&lt;br&gt;
results. We call its output pseudo-random as the output we get is not&lt;br&gt;
100% random, but still is, pretty much random. &lt;/p&gt;

&lt;p&gt;This script will ask the user whether to roll the dice or exit the game.&lt;br&gt;
If the user chooses to roll the dice, the script will use the random&lt;br&gt;
module, to get a random number between 1 and 6 and display it to the&lt;br&gt;
user. If the user chooses to exit, the program will simply exit.&lt;/p&gt;

&lt;p&gt;You can find this project source code&lt;br&gt;
&lt;a href="https://github.com/visheshdvivedi/Top-10-Easy-Python-Project-Ideas-For-Beginners/blob/main/dice_rolling.py" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Number Guessing Game
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-yE8mjMltBsM/YRqudbnP1YI/AAAAAAAAAc4/UoCDKKte87ce88g3Jtw_apLnft0TA8AFgCLcBGAsYHQ/s1920/simple%2Bpython%2Bprojects%2Bfor%2Bbeginners%2Bwith%2Bsource%2Bcode%2B-%2Bnumber%2Bguessing%2Bgame.jpg" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-yE8mjMltBsM%2FYRqudbnP1YI%2FAAAAAAAAAc4%2FUoCDKKte87ce88g3Jtw_apLnft0TA8AFgCLcBGAsYHQ%2Fw640-h480%2Fsimple%252Bpython%252Bprojects%252Bfor%252Bbeginners%252Bwith%252Bsource%252Bcode%252B-%252Bnumber%252Bguessing%252Bgame.jpg" title="simple python projects for beginners with source code - number guessing game" alt="simple python projects for beginners with source code - number&amp;lt;br&amp;gt;
guessing&amp;lt;br&amp;gt;
game"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This project is similar to the dice rolling simulator, which means that&lt;br&gt;
this project also uses the random module to generate random numbers.&lt;br&gt;
However, this project also has some extra logic in it, that turns this&lt;br&gt;
project into a fun game to play.&lt;/p&gt;

&lt;p&gt;In this game, the script will randomly get a number between 1 and 10 and&lt;br&gt;
the user has to guess which number it is. Depending on the user’s&lt;br&gt;
entered number, the script will tell if the actual number is greater&lt;br&gt;
than or less than the original number. In the end, the script will tell&lt;br&gt;
how many tries the user took to guess the number.&lt;/p&gt;

&lt;p&gt;You can find this project source code&lt;br&gt;
&lt;a href="https://github.com/visheshdvivedi/Top-10-Easy-Python-Project-Ideas-For-Beginners/blob/main/number_guessing.py" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Value Converter
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-_tEasoZ3VpA/YRquoXUZsvI/AAAAAAAAAdA/B6Mt9jpnCbMEl48bktHBZHdyO_61arYYwCLcBGAsYHQ/s1920/simple%2Bpython%2Bprojects%2Bfor%2Bbeginners%2Bwith%2Bsource%2Bcode%2B-%2Bvalue%2Bconverter.jpg" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-_tEasoZ3VpA%2FYRquoXUZsvI%2FAAAAAAAAAdA%2FB6Mt9jpnCbMEl48bktHBZHdyO_61arYYwCLcBGAsYHQ%2Fw640-h426%2Fsimple%252Bpython%252Bprojects%252Bfor%252Bbeginners%252Bwith%252Bsource%252Bcode%252B-%252Bvalue%252Bconverter.jpg" title="simple python projects for beginners with source code - value converter" alt="simple python projects for beginners with source code - value&amp;lt;br&amp;gt;
converter"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Its name can be a bit confusing to understand, but the project in itself&lt;br&gt;
is very easy to make. The script that we will make within this project,&lt;br&gt;
will be used to perform some common conversions between different&lt;br&gt;
measurement units, like Celsius to Fahrenheit, rupee to pound,&lt;br&gt;
centimeter to foot, etc. &lt;/p&gt;

&lt;p&gt;Initially, this script will only be able to perform some basic&lt;br&gt;
conversions that require very basic mathematics. But as you improve your&lt;br&gt;
programming skills, and get introduced to the NumPy library, you can add&lt;br&gt;
the functionality of doing some more complex conversions like&lt;br&gt;
calculating the area and perimeter of a circle with a given radius. (you&lt;br&gt;
would need the value of pi for this conversion, which you can get from&lt;br&gt;
the NumPy library)&lt;/p&gt;

&lt;p&gt;You can find this project source code&lt;br&gt;
&lt;a href="https://github.com/visheshdvivedi/Top-10-Easy-Python-Project-Ideas-For-Beginners/blob/main/value_converter.py" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Countdown Timer
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-D8vtbvu1sU4/YRquxFT6rAI/AAAAAAAAAdI/B-J2XnEPCGU0nCCfcr5B8QW3tj6WTB0IQCLcBGAsYHQ/s1920/simple%2Bpython%2Bprojects%2Bfor%2Bbeginners%2Bwith%2Bsource%2Bcode%2B-%2Bcountdown%2Btimer.jpg" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-D8vtbvu1sU4%2FYRquxFT6rAI%2FAAAAAAAAAdI%2FB-J2XnEPCGU0nCCfcr5B8QW3tj6WTB0IQCLcBGAsYHQ%2Fw640-h590%2Fsimple%252Bpython%252Bprojects%252Bfor%252Bbeginners%252Bwith%252Bsource%252Bcode%252B-%252Bcountdown%252Btimer.jpg" title="simple python projects for beginners with source code - countdown timer" alt="simple python projects for beginners with source code - countdown&amp;lt;br&amp;gt;
timer"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Its name is pretty self-explanatory. Within this project, we will create&lt;br&gt;
a script that will have the ability to start a countdown timer for a&lt;br&gt;
certain amount of time. The user will first enter the number of seconds&lt;br&gt;
that the countdown should count, Once the amount is entered, the script&lt;br&gt;
will start the countdown and the script will wait for the entered amount&lt;br&gt;
of seconds to complete.&lt;/p&gt;

&lt;p&gt;It will work just like a countdown that you can find on your watch or&lt;br&gt;
smartphone.&lt;/p&gt;

&lt;p&gt;You can find the project source code&lt;br&gt;
&lt;a href="https://github.com/visheshdvivedi/Top-10-Easy-Python-Project-Ideas-For-Beginners/blob/main/countdown_timer.py" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Password Strength Checker
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-y29Kk-XqLVg/YRqu45F5ycI/AAAAAAAAAdQ/Q05g8UicG4EYCb0PXL3vgNyznBquDzfHgCLcBGAsYHQ/s1920/simple%2Bpython%2Bprojects%2Bfor%2Bbeginners%2Bwith%2Bsource%2Bcode%2B-%2Bpassword%2Bstrength%2Bchecker.jpg" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-y29Kk-XqLVg%2FYRqu45F5ycI%2FAAAAAAAAAdQ%2FQ05g8UicG4EYCb0PXL3vgNyznBquDzfHgCLcBGAsYHQ%2Fw640-h418%2Fsimple%252Bpython%252Bprojects%252Bfor%252Bbeginners%252Bwith%252Bsource%252Bcode%252B-%252Bpassword%252Bstrength%252Bchecker.jpg" title="simple python projects for beginners with source code - password strength checker" alt="simple python projects for beginners with source code - password&amp;lt;br&amp;gt;
strength&amp;lt;br&amp;gt;
checker"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Whenever you create an account on a site by entering your username and&lt;br&gt;
password, the site ensures that the password you are trying to save is&lt;br&gt;
strong, so that hackers cannot guess your passwords easily.&lt;/p&gt;

&lt;p&gt;In this project, we are gonna mimic the site, functionality into a&lt;br&gt;
console-based python project, This script will check the strength of the&lt;br&gt;
password that the user will enter. The script will show the number of&lt;br&gt;
alphabets, numbers, special characters, and whitespace characters&lt;br&gt;
present within the password and will accordingly mark the password’s&lt;br&gt;
strength.&lt;/p&gt;

&lt;p&gt;The best password will be the one containing at least one uppercase&lt;br&gt;
letter, one lowercase letter, one digit, one special character, and one&lt;br&gt;
whitespace. So it’s time you change your Gmail password.&lt;/p&gt;

&lt;p&gt;You can find this project source code&lt;br&gt;
&lt;a href="https://github.com/visheshdvivedi/Top-10-Easy-Python-Project-Ideas-For-Beginners/blob/main/password_strength_checker.py" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Hangman Game
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-XwlML13RWlM/YRqvArTo_cI/AAAAAAAAAdU/q3UrQKvVCTM3iwNCHT_EPZLuZmNX9WozwCLcBGAsYHQ/s1920/simple%2Bpython%2Bprojects%2Bfor%2Bbeginners%2Bwith%2Bsource%2Bcode%2B-%2Bhangman.jpg" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-XwlML13RWlM%2FYRqvArTo_cI%2FAAAAAAAAAdU%2Fq3UrQKvVCTM3iwNCHT_EPZLuZmNX9WozwCLcBGAsYHQ%2Fw640-h480%2Fsimple%252Bpython%252Bprojects%252Bfor%252Bbeginners%252Bwith%252Bsource%252Bcode%252B-%252Bhangman.jpg" title="simple python projects for beginners with source code - hangman" alt="simple python projects for beginners with source code -&amp;lt;br&amp;gt;
hangman"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Do you remember this game that you used to play? where your friend would&lt;br&gt;
guess a letter and write the number of letters in the word in the form&lt;br&gt;
of underscores and then you would have to guess the word in few chances?&lt;br&gt;
This project is exactly this game but made in python.&lt;/p&gt;

&lt;p&gt;Hangman is again a very common project to be built by beginner&lt;br&gt;
programmers. In this game, the script will randomly pick a word from a&lt;br&gt;
list of words, show to the user the number of letters in the word and&lt;br&gt;
the user has to guess the word by guessing each letter that may appear&lt;br&gt;
in the word. The user will have 7 chances to guess a letter that may be&lt;br&gt;
present within the word. If he or she is unable to guess the word within&lt;br&gt;
7 chances, the user will lose the game.&lt;/p&gt;

&lt;p&gt;You can create this project and have fun with your friends while showing&lt;br&gt;
off your programming skills (definitely gonna impress some girls :D)&lt;/p&gt;

&lt;p&gt;You can find this project source code&lt;br&gt;
&lt;a href="https://github.com/visheshdvivedi/Top-10-Easy-Python-Project-Ideas-For-Beginners/blob/main/hangman.py" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Tic Tac Toe
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-OJe3MjV2mRI/YRqvIHBij2I/AAAAAAAAAdc/Q4A9DCAxHt8RlLnMVPz6BkIdNyBTahkVACLcBGAsYHQ/s1920/simple%2Bpython%2Bprojects%2Bfor%2Bbeginners%2Bwith%2Bsource%2Bcode%2B-%2Btic%2Btac%2Btoe.jpg" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-OJe3MjV2mRI%2FYRqvIHBij2I%2FAAAAAAAAAdc%2FQ4A9DCAxHt8RlLnMVPz6BkIdNyBTahkVACLcBGAsYHQ%2Fw640-h562%2Fsimple%252Bpython%252Bprojects%252Bfor%252Bbeginners%252Bwith%252Bsource%252Bcode%252B-%252Btic%252Btac%252Btoe.jpg" title="simple python projects for beginners with source code - tic tac toe" alt="simple python projects for beginners with source code - tic tac&amp;lt;br&amp;gt;
toe"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you haven’t heard of this game, or have not played it before, you&lt;br&gt;
must have had a rough childhood, just kidding :D.&lt;/p&gt;

&lt;p&gt;Tic tac toe is a popular, two-player game that involves two players&lt;br&gt;
playing on a 3 by 3 board, where each player tries to make three&lt;br&gt;
consecutive of their mark. Whoever is able to do it, will win, else&lt;br&gt;
there will be a tie. This project will try to make a tic tac toe game in&lt;br&gt;
python as a console application. The application would require an&lt;br&gt;
understanding about 2D lists in python.&lt;/p&gt;

&lt;p&gt;Not only you can create this project, but you can also create an&lt;br&gt;
undefeatable version of the tic tac toe game in python. If you wanna&lt;br&gt;
know how to make it, you can check out this blog&lt;br&gt;
&lt;a href="https://itsallaboutpython.blogspot.com/2021/05/create-undefeatable-tic-tac-toe-in.html" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can find the project source code&lt;br&gt;
&lt;a href="https://github.com/visheshdvivedi/Top-10-Easy-Python-Project-Ideas-For-Beginners/blob/main/tic_tac_toe.py" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  9. Rock, Paper, Scissor
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-_nxoo75e5zY/YRqvQItMFlI/AAAAAAAAAdo/gv8p6Wpv0hcHmx6AzwpXj756o5MdwmEjwCLcBGAsYHQ/s1920/simple%2Bpython%2Bprojects%2Bfor%2Bbeginners%2Bwith%2Bsource%2Bcode%2B-%2Brock%2Bpaper%2Bscissor.jpg" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-_nxoo75e5zY%2FYRqvQItMFlI%2FAAAAAAAAAdo%2Fgv8p6Wpv0hcHmx6AzwpXj756o5MdwmEjwCLcBGAsYHQ%2Fw640-h426%2Fsimple%252Bpython%252Bprojects%252Bfor%252Bbeginners%252Bwith%252Bsource%252Bcode%252B-%252Brock%252Bpaper%252Bscissor.jpg" title="simple python projects for beginners with source code - rock paper scissor" alt="simple python projects for beginners with source code - rock paper&amp;lt;br&amp;gt;
scissor"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This project will mimic the rock paper scissor game, which I am very&lt;br&gt;
sure you will know, Here the user will act as one player, and the&lt;br&gt;
computer will act as another user. While the user will choose an object&lt;br&gt;
from rock, paper, and scissors, the script will also choose an object.&lt;br&gt;
Based on user choice, the script will see who won and show the output to&lt;br&gt;
the user.&lt;/p&gt;

&lt;p&gt;You can find the project source code&lt;br&gt;
&lt;a href="https://github.com/visheshdvivedi/Top-10-Easy-Python-Project-Ideas-For-Beginners/blob/main/rock_paper_scissor.py" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  10. User Record Management System
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/--4tA5Kz7c90/YRqvXiVYNTI/AAAAAAAAAdw/bfRq-8X0WBQ-3HFjtUVzbCJATItBDRgUACLcBGAsYHQ/s1920/simple%2Bpython%2Bprojects%2Bfor%2Bbeginners%2Bwith%2Bsource%2Bcode%2B-%2Buser%2Brecord%2Bmanagement%2Bsystem.jpg" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F--4tA5Kz7c90%2FYRqvXiVYNTI%2FAAAAAAAAAdw%2FbfRq-8X0WBQ-3HFjtUVzbCJATItBDRgUACLcBGAsYHQ%2Fw640-h372%2Fsimple%252Bpython%252Bprojects%252Bfor%252Bbeginners%252Bwith%252Bsource%252Bcode%252B-%252Buser%252Brecord%252Bmanagement%252Bsystem.jpg" title="simple python projects for beginners with source code - user record management system" alt="simple python projects for beginners with source code - user record&amp;lt;br&amp;gt;
management&amp;lt;br&amp;gt;
system"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have you ever wondered how the software that manages the data of&lt;br&gt;
millions of users works? maybe you can make a smaller version of that&lt;br&gt;
software using python.  &lt;/p&gt;

&lt;p&gt;This project will focus on clearly understanding the concept of CRUD&lt;br&gt;
operation, which is created, read, update and delete. The script will&lt;br&gt;
maintain a database within python dictionary and provide users with the&lt;br&gt;
option to create an entry, read a single or all entries, update any&lt;br&gt;
existing entry, or delete any entry. Those who are aware about OOP can&lt;br&gt;
also attempt to create this project while following the OOP paradigm. &lt;/p&gt;

&lt;p&gt;You can find the project source code&lt;br&gt;
&lt;a href="https://github.com/visheshdvivedi/Top-10-Easy-Python-Project-Ideas-For-Beginners/blob/main/user_management_system.py" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Those were the top 10 easy python projects for beginners. I have created&lt;br&gt;
these 10 projects for you all and uploaded them on GitHub, you can find&lt;br&gt;
the link&lt;br&gt;
&lt;a href="https://github.com/visheshdvivedi/Top-10-Easy-Python-Project-Ideas-For-Beginners" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But honestly, I would want you all to try building these projects by&lt;br&gt;
yourself as it will add more value to your programming skills.&lt;br&gt;
Obviously, you can contact me anytime on Instagram, or by joining my&lt;br&gt;
discord server. I will try my best to respond to your queries as&lt;br&gt;
accurately as possible. &lt;/p&gt;

&lt;p&gt; If you liked this post, don’t forget to check out my other posts.&lt;/p&gt;

&lt;p&gt;You can also check out my YouTube channel&lt;br&gt;
&lt;a href="https://youtube.com/allaboutpython?sub_confirmation=1" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for watching and take care&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Simple Script To Send Emails In Python</title>
      <dc:creator>Vishesh Dvivedi</dc:creator>
      <pubDate>Thu, 28 Oct 2021 06:02:57 +0000</pubDate>
      <link>https://dev.to/visheshdvivedi/simple-script-to-send-emails-in-python-11ee</link>
      <guid>https://dev.to/visheshdvivedi/simple-script-to-send-emails-in-python-11ee</guid>
      <description>&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-NlhES-ojmpE/YR1NQnS04KI/AAAAAAAAAeA/S22tLiOAdaMIEjtTZhQ-Pxw15cTZ9_JKQCLcBGAsYHQ/s1280/Simple%2BScript%2BTo%2BSend%2BEmails%2BIn%2BPython%2B-%2BEmails.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-NlhES-ojmpE%2FYR1NQnS04KI%2FAAAAAAAAAeA%2FS22tLiOAdaMIEjtTZhQ-Pxw15cTZ9_JKQCLcBGAsYHQ%2Fw640-h358%2FSimple%252BScript%252BTo%252BSend%252BEmails%252BIn%252BPython%252B-%252BEmails.png" title="Simple Script To Send Emails In Python - Emails" alt="Simple Script To Send Emails In Python -&amp;lt;br&amp;gt;
Emails"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Email" rel="noopener noreferrer"&gt;Emails&lt;/a&gt; are, nowadays, a common way of formal communication, which is also good for the transfer of files easily from person to person. Almost every person who has some identity over the internet, or simply uses it, has an email ID of his own, be it &lt;a href="https://en.wikipedia.org/wiki/Gmail" rel="noopener noreferrer"&gt;Gmail&lt;/a&gt; or &lt;a href="https://en.wikipedia.org/wiki/Microsoft_Outlook" rel="noopener noreferrer"&gt;outlook&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now of all the awesome stuff that can be done in python, one of those is to be able to send or receive &lt;a href="https://en.wikipedia.org/wiki/Email" rel="noopener noreferrer"&gt;emails&lt;/a&gt;. Python programming&lt;br&gt;
libraries can be used to send mails or to list all the mails within your email account. You can also perform some basic actions, like marking the mail as read, using python.&lt;/p&gt;

&lt;p&gt;And in this blog, I am gonna show you, how you can do this yourself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;About Mail Servers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-alQJy_Z_noE/YR1NmQV9u_I/AAAAAAAAAeI/fQ1lEWQGBB0tapeGv5XBTTOx8-1PeBuDgCLcBGAsYHQ/s2997/Simple%2BScript%2BTo%2BSend%2BEmails%2BIn%2BPython%2B-%2BSMTP%2Band%2BIMAP%2BMail%2BServers.jpg" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-alQJy_Z_noE%2FYR1NmQV9u_I%2FAAAAAAAAAeI%2FfQ1lEWQGBB0tapeGv5XBTTOx8-1PeBuDgCLcBGAsYHQ%2Fw640-h224%2FSimple%252BScript%252BTo%252BSend%252BEmails%252BIn%252BPython%252B-%252BSMTP%252Band%252BIMAP%252BMail%252BServers.jpg" title="Simple Script To Send Emails In Python - SMTP and IMAP Mail Servers" alt="Simple Script To Send Emails In Python - SMTP and IMAP Mail&amp;lt;br&amp;gt;
Servers"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before we start with the coding part, you need to have some basic&lt;br&gt;
information about mails and mail servers.&lt;/p&gt;

&lt;p&gt;Mail servers are basically servers that are used to manage &lt;a href="https://en.wikipedia.org/wiki/Email" rel="noopener noreferrer"&gt;emails&lt;/a&gt;, &lt;a href="https://en.wikipedia.org/wiki/Microsoft_Outlook" rel="noopener noreferrer"&gt;Outlook&lt;/a&gt;, &lt;a href="https://en.wikipedia.org/wiki/Gmail" rel="noopener noreferrer"&gt;Gmail&lt;/a&gt;, Yahoo, Hotmail, etc. have their own mail servers that manage their mail services. Mail servers can further be classified into two categories;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SMTP Server&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;SMTP stands for &lt;a href="https://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol" rel="noopener noreferrer"&gt;Simple Mail Transfer Protocol&lt;/a&gt;.This server is responsible for sending or transferring mail from server to server i.e. whenever you send a mail to someone, you typically make use of the SMTP server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;IMAP Server&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;IMAP stands for &lt;a href="https://en.wikipedia.org/wiki/Internet_Message_Access_Protocol" rel="noopener noreferrer"&gt;Internet Message Access Protocol&lt;/a&gt;.This server is responsible for storing and listing mails from your server i.e. whenever you open your &lt;a href="https://en.wikipedia.org/wiki/Gmail" rel="noopener noreferrer"&gt;Gmail&lt;/a&gt; or &lt;a href="https://en.wikipedia.org/wiki/Microsoft_Outlook" rel="noopener noreferrer"&gt;Outlook&lt;/a&gt;, you typically make use of the IMAP server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SSL and TLS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are two types of encryption protocols used for&lt;br&gt;
&lt;a href="https://en.wikipedia.org/wiki/Email" rel="noopener noreferrer"&gt;emails&lt;/a&gt;, SSL (&lt;a href="https://en.wikipedia.org/wiki/Transport_Layer_Security#SSL_1.0,_2.0,_and_3.0" rel="noopener noreferrer"&gt;Secure Socket Layer&lt;/a&gt;) and TLS (&lt;a href="https://en.wikipedia.org/wiki/Transport_Layer_Security" rel="noopener noreferrer"&gt;Transport Layer Security&lt;/a&gt;).&lt;br&gt;
Whenever you will connect to any mail server, you will connect through one of these protocols. Each protocol has its port assigned to the server.&lt;/p&gt;

&lt;p&gt;TLS - port 587&lt;br&gt;
SSL - port 465&lt;/p&gt;

&lt;p&gt;Although &lt;a href="https://en.wikipedia.org/wiki/Gmail" rel="noopener noreferrer"&gt;Gmail&lt;/a&gt; and &lt;a href="https://en.wikipedia.org/wiki/Microsoft_Outlook" rel="noopener noreferrer"&gt;Outlook&lt;/a&gt; server support both these protocols, we are gonna use only TLS protocol in this post for simplicity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sending Mails using Python&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-lkyurw5VAtI/YR1OAnZAUaI/AAAAAAAAAeQ/xbT0ZOWMRNIDmzKLnDOs_dvsuakk7G_KACLcBGAsYHQ/s1280/Simple%2BScript%2BTo%2BSend%2BEmails%2BIn%2BPython%2B-%2BSending%2Bmails%2Busing%2Bpython.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-lkyurw5VAtI%2FYR1OAnZAUaI%2FAAAAAAAAAeQ%2FxbT0ZOWMRNIDmzKLnDOs_dvsuakk7G_KACLcBGAsYHQ%2Fw640-h432%2FSimple%252BScript%252BTo%252BSend%252BEmails%252BIn%252BPython%252B-%252BSending%252Bmails%252Busing%252Bpython.png" title="Simple Script To Send Emails In Python - sending mails using python" alt="Simple Script To Send Emails In Python - sending mails using&amp;lt;br&amp;gt;
python"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that we are clear about mail servers, let's create our first script to send mail using python&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installing the library&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-eeDjAGu_aLA/YR1OWkDQwxI/AAAAAAAAAeY/wo06MeFGVRgWl3OiRFFy3239_XEkmz7OgCLcBGAsYHQ/s2048/Simple%2BScript%2BTo%2BSend%2BEmails%2BIn%2BPython%2B-%2Bpython%2Blibrary%2Bto%2Bsend%2Bmails.jpg" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-eeDjAGu_aLA%2FYR1OWkDQwxI%2FAAAAAAAAAeY%2Fwo06MeFGVRgWl3OiRFFy3239_XEkmz7OgCLcBGAsYHQ%2Fw640-h426%2FSimple%252BScript%252BTo%252BSend%252BEmails%252BIn%252BPython%252B-%252Bpython%252Blibrary%252Bto%252Bsend%252Bmails.jpg" title="Simple Script To Send Emails In Python - python library to send mails" alt="Simple Script To Send Emails In Python - python library to send&amp;lt;br&amp;gt;
mails"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will be using the smtplib library of python to send &lt;a href="https://en.wikipedia.org/wiki/Gmail" rel="noopener noreferrer"&gt;Gmail&lt;/a&gt; or &lt;a href="https://en.wikipedia.org/wiki/Microsoft_Outlook" rel="noopener noreferrer"&gt;Outlook&lt;/a&gt; mail. This library comes built-in in python, so you don't need to download it from elsewhere.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating the script&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here's how the script would look like&lt;/p&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-uHUX2Nso6uQ/YR1OxolUNqI/AAAAAAAAAeg/DRGyTX_tZjEaH6XIUj5f0AXftEiu3lMzwCLcBGAsYHQ/s1366/Simple%2BScript%2BTo%2BSend%2BEmails%2BIn%2BPython%2B-%2Bpython%2Bscript%2Bto%2Bsend%2Bmails.PNG" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-uHUX2Nso6uQ%2FYR1OxolUNqI%2FAAAAAAAAAeg%2FDRGyTX_tZjEaH6XIUj5f0AXftEiu3lMzwCLcBGAsYHQ%2Fw640-h342%2FSimple%252BScript%252BTo%252BSend%252BEmails%252BIn%252BPython%252B-%252Bpython%252Bscript%252Bto%252Bsend%252Bmails.PNG" title="Simple Script To Send Emails In Python - python script to send mails" alt="Simple Script To Send Emails In Python - python script to send&amp;lt;br&amp;gt;
mails"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The script may look complicated, but we will go line-by-line to discuss each function and class of the script and understand its use&lt;/p&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-z-rc47TPTEQ/YR1PQRCKI7I/AAAAAAAAAeo/oVF72gI7pvwPB4ERR23uN8TSpmqs0fV3wCLcBGAsYHQ/s152/Simple%2BScript%2BTo%2BSend%2BEmails%2BIn%2BPython%2B-%2Bimport%2Blibraries.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-z-rc47TPTEQ%2FYR1PQRCKI7I%2FAAAAAAAAAeo%2FoVF72gI7pvwPB4ERR23uN8TSpmqs0fV3wCLcBGAsYHQ%2Fw400-h124%2FSimple%252BScript%252BTo%252BSend%252BEmails%252BIn%252BPython%252B-%252Bimport%252Blibraries.png" title="Simple python script to send emails - import libraries" alt="Simple python script to send emails - import&amp;lt;br&amp;gt;
libraries"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The script starts with importing smtplib and getpass library. We are using the getpass library so that we can retrieve the password from the&lt;br&gt;
user.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-wDGAtsEE83s/YR1Q8BOJQnI/AAAAAAAAAew/KQnYH71cEcEZy7RAVeQtFhQ8NzL6XHocACLcBGAsYHQ/s403/Simple%2BScript%2BTo%2BSend%2BEmails%2BIn%2BPython%2B-%2Bemail%2Band%2Bpassword.PNG" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-wDGAtsEE83s%2FYR1Q8BOJQnI%2FAAAAAAAAAew%2FKQnYH71cEcEZy7RAVeQtFhQ8NzL6XHocACLcBGAsYHQ%2Fw400-h84%2FSimple%252BScript%252BTo%252BSend%252BEmails%252BIn%252BPython%252B-%252Bemail%252Band%252Bpassword.PNG" title="simple script to send emails in python - email and password" alt="simple script to send emails in python - email and&amp;lt;br&amp;gt;
password"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After that, we ask the user to enter the credentials for their mail account, which will be used to send the mail. We use getpass to ask the user for the password. Since we are using getpass, the password that the user will enter will not be displayed on the screen but will be saved within the variable.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/--nIYKydzfNo/YR1RNf-1UKI/AAAAAAAAAe4/LAX8PHAS4Gkmd9wrcu40gA2g0i-dlq8DgCLcBGAsYHQ/s434/Simple%2BScript%2BTo%2BSend%2BEmails%2BIn%2BPython%2B-%2Bset%2Bhost%2Band%2Bport.PNG" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F--nIYKydzfNo%2FYR1RNf-1UKI%2FAAAAAAAAAe4%2FLAX8PHAS4Gkmd9wrcu40gA2g0i-dlq8DgCLcBGAsYHQ%2Fw400-h194%2FSimple%252BScript%252BTo%252BSend%252BEmails%252BIn%252BPython%252B-%252Bset%252Bhost%252Band%252Bport.PNG" title="simple script to send emails in python - set host and port" alt="simple script to send emails in python - set host and&amp;lt;br&amp;gt;
port"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the next step, we set up the SMTP server host and port to be used. If the entered email ID is a &lt;a href="https://en.wikipedia.org/wiki/Gmail" rel="noopener noreferrer"&gt;Gmail&lt;/a&gt; account, the host will be set to &lt;a href="https://en.wikipedia.org/wiki/Gmail" rel="noopener noreferrer"&gt;Gmail&lt;/a&gt; SMTP server, or else if it is &lt;a href="https://en.wikipedia.org/wiki/Microsoft_Outlook" rel="noopener noreferrer"&gt;Outlook&lt;/a&gt;, the ost&lt;br&gt;
will be set to &lt;a href="https://en.wikipedia.org/wiki/Microsoft_Outlook" rel="noopener noreferrer"&gt;Outlook&lt;/a&gt; SMTP server.&lt;br&gt;
We set the port to 587 as we had discussed above within the 'SSL and TLS heading. In case if the entered email ID cannot be identified as &lt;a href="https://en.wikipedia.org/wiki/Gmail" rel="noopener noreferrer"&gt;Gmail&lt;/a&gt; or&lt;br&gt;
&lt;a href="https://en.wikipedia.org/wiki/Microsoft_Outlook" rel="noopener noreferrer"&gt;Outlook&lt;/a&gt;, the script will give an error message and exit.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-cUFEIlwJ1yM/YR1RXHQteoI/AAAAAAAAAe8/S_Q-rUbNlAE4Llw-Pd9gMuPfMJJ4GPnWQCLcBGAsYHQ/s461/Simple%2BScript%2BTo%2BSend%2BEmails%2BIn%2BPython%2B-%2Bsmtplib.SMTP%2Bclass%2Bobject.PNG" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-cUFEIlwJ1yM%2FYR1RXHQteoI%2FAAAAAAAAAe8%2FS_Q-rUbNlAE4Llw-Pd9gMuPfMJJ4GPnWQCLcBGAsYHQ%2Fw400-h139%2FSimple%252BScript%252BTo%252BSend%252BEmails%252BIn%252BPython%252B-%252Bsmtplib.SMTP%252Bclass%252Bobject.PNG" title="simple script to send emails in python - smtplib.SMTP class object" alt="simple script to send emails in python - smtplib.SMTP class&amp;lt;br&amp;gt;
object"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the next step, we will create the SMTP class object, which will be used to perform the actions. We create an object of smtplib.SMTP class and save the object by the name 'server'. The class object requires two parameters, the hostname, and the port. &lt;/p&gt;

&lt;p&gt;Once we have created the object, we call the ehlo() function of the class object, which is basically used to send a greeting message to the mail server. This step is crucial, as not performing this step may cause problems in communicating with the mail server. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-QAltlFCcouA/YR1Rf9sAzmI/AAAAAAAAAfE/Yvr9_HpdvDsV6sc37BErPvIo9P6SgJk5QCLcBGAsYHQ/s537/Simple%2BScript%2BTo%2BSend%2BEmails%2BIn%2BPython%2B-%2Bstart%2Btls%2Bencryption.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-QAltlFCcouA%2FYR1Rf9sAzmI%2FAAAAAAAAAfE%2FYvr9_HpdvDsV6sc37BErPvIo9P6SgJk5QCLcBGAsYHQ%2Fw400-h41%2FSimple%252BScript%252BTo%252BSend%252BEmails%252BIn%252BPython%252B-%252Bstart%252Btls%252Bencryption.png" title="simple script to send emails in python - start tls encryption" alt="simple script to send emails in python - start tls&amp;lt;br&amp;gt;
encryption"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After receiving a successful response from the server, we call the starttls() function to start TLS encryption. This step is only required for TLS connection and not for SSL connection.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-o88SInWtQ6Q/YR1R4HZC88I/AAAAAAAAAfU/nEAcbcKHrzoRjv4qOHB-FNbkqiPMRB8aQCLcBGAsYHQ/s426/Simple%2BScript%2BTo%2BSend%2BEmails%2BIn%2BPython%2B-%2Blogin%2Bto%2Bmail%2Bserver.PNG" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-o88SInWtQ6Q%2FYR1R4HZC88I%2FAAAAAAAAAfU%2FnEAcbcKHrzoRjv4qOHB-FNbkqiPMRB8aQCLcBGAsYHQ%2Fw400-h153%2FSimple%252BScript%252BTo%252BSend%252BEmails%252BIn%252BPython%252B-%252Blogin%252Bto%252Bmail%252Bserver.PNG" title="simple script to send emails in python - login to mail server" alt="simple script to send emails in python - login to mail&amp;lt;br&amp;gt;
server"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After this, we call the login() function to log in to the mail account. The function requires two parameters, the email ID and the password, which we had retrieved from the user.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-E0rbx8h68ME/YR1R_gXFJTI/AAAAAAAAAfc/ASO4-kqbgCs0EaiAzU0HQGZS9iUK_umsACLcBGAsYHQ/s458/Simple%2BScript%2BTo%2BSend%2BEmails%2BIn%2BPython%2B-%2Bget%2Bemail%2Bcontent.PNG" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-E0rbx8h68ME%2FYR1R_gXFJTI%2FAAAAAAAAAfc%2FASO4-kqbgCs0EaiAzU0HQGZS9iUK_umsACLcBGAsYHQ%2Fw400-h106%2FSimple%252BScript%252BTo%252BSend%252BEmails%252BIn%252BPython%252B-%252Bget%252Bemail%252Bcontent.PNG" title="simple script to send emails in python - get email content from user" alt="simple script to send emails in python - get email content from user"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once we have successfully logged in, we ask the user for the receiver's email ID, mail's subject, and mail body.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-eytSNF_SFSs/YR1SHvioJfI/AAAAAAAAAfg/I1r1aQfn-SMukMEHE9V36aZY_yrOU8eEwCLcBGAsYHQ/s495/Simple%2BScript%2BTo%2BSend%2BEmails%2BIn%2BPython%2B-%2Bsend%2Bmail.PNG" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F1.bp.blogspot.com%2F-eytSNF_SFSs%2FYR1SHvioJfI%2FAAAAAAAAAfg%2FI1r1aQfn-SMukMEHE9V36aZY_yrOU8eEwCLcBGAsYHQ%2Fw400-h125%2FSimple%252BScript%252BTo%252BSend%252BEmails%252BIn%252BPython%252B-%252Bsend%252Bmail.PNG" title="simple script to send emails in python - sendmail function" alt="simple script to send emails in python - sendmail&amp;lt;br&amp;gt;
function"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And finally, we call the sendmail() function and pass three parameters, sender mail ID, receiver mail ID, and the mail body (created by merging mail subject and mail content).&lt;/p&gt;

&lt;p&gt;Here is the full code &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import smtplib
import getpass

# Get email ID and password from user
email = input("Enter email ID: ")
password = getpass.getpass("Enter password: ")

# Set SMTP host and port
if "gmail" in email:
    host = "smtp.gmail.com"
    port = 587
elif "outlook" in email:
    host = "smtp-mail.outlook.com"
    port = 587
else:
    print("Invalid email ID, please try again")
    exit(0)

# Create SMTPLib object and contact server
server = smtplib.SMTP(host, port)
check = server.ehlo()
if check[0] == 250:
    print("Successfully contacted mail server")
else:
    print("Unable to contact server")
    exit(0)

# Start TLS encryption (only to be done if conencting to port 587 i.e. TLS)
server.starttls()

# Logging into the server
try:
    server.login(email, password)
    print("Login successful")
except smtplib.SMTPAuthenticationError as ex:     
    print("Exception:", ex)    
    exit(0)

# Get email details from user
sender_mail = email
receiver_email = input("Enter receiver's email: ")
subject = input("Enter email subject: ")
content = input("Enter email content: ")

# Create email body by merging emails object and content
body = "Subject: " + subject + '\n' + content

# Send the mail
output = server.sendmail(sender_mail, receiver_email, body)
if not len(output):
    print("Send mail successfully")
else:
    print("Unable to send mail, please try again")    
    exit(0)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And that's it, you have successfully sent a mail through python&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this blog, I have only covered sending mail through python. I will soon create another blog that will deal with accessing email from accounts by contacting the IMAP servers using python.&lt;/p&gt;

&lt;p&gt;Hope you liked this blog&lt;/p&gt;

&lt;p&gt;Stay safe, stay blessed, and thanks for reading.&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Zip Function In Python</title>
      <dc:creator>Vishesh Dvivedi</dc:creator>
      <pubDate>Wed, 27 Oct 2021 18:13:56 +0000</pubDate>
      <link>https://dev.to/visheshdvivedi/zip-function-in-python-2eak</link>
      <guid>https://dev.to/visheshdvivedi/zip-function-in-python-2eak</guid>
      <description>&lt;p&gt;&lt;a href="https://1.bp.blogspot.com/-WojgyW30-P4/YSny-vAyA6I/AAAAAAAAAf4/vlZKnYgRo3Ux8TYYzjmNTp1Q5XHbF0aAACLcBGAsYHQ/s1280/All%2BAbout%2Bthe%2BZip%2BFunction%2BIn%2BPython.png" rel="noopener noreferrer"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--26uw3zQF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://1.bp.blogspot.com/-WojgyW30-P4/YSny-vAyA6I/AAAAAAAAAf4/vlZKnYgRo3Ux8TYYzjmNTp1Q5XHbF0aAACLcBGAsYHQ/w640-h360/All%252BAbout%252Bthe%252BZip%252BFunction%252BIn%252BPython.png" title="All About the Zip Function In Python" alt="All About the Zip Function In&amp;lt;br&amp;gt;
Python" width="640" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The zip function in python is a great function that is used to merge two&lt;br&gt;
or more iterable items into one, and that too by index. It's a built-in&lt;br&gt;
function of python language which can make your life easy when you have&lt;br&gt;
data with different formats but need to join them somehow.&lt;/p&gt;

&lt;p&gt;Before we start with the zip function, let's talk about the iterable&lt;br&gt;
data types in python.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Iterable Data Types In Python&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Iterable data types are basically those data types that can be iterated&lt;br&gt;
i.e. a for-in-the-loop can be used to go through each element within&lt;br&gt;
them. Some examples of iterable data types are lists, tuples, sets, etc.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lists_example = [1, 2, 3, 4, 5]
tuple_example = (1, 2, 3)
sets_example = {1, 2, 3}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Any of these data types can be passed onto a for-in loop which will&lt;br&gt;
iterate through each of their elements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What does the zip() function has to do with iterable data types?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Assume a situation where you have to display data of students that study&lt;br&gt;
in a school. You happen the have to have lists of data of students. But&lt;br&gt;
the catch here is that all the names are in one list, and all their&lt;br&gt;
student IDs are on one list, like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;student_names = ["Alex", "Murphy", "Jinny", "George"]
student_ids = [700405, 700465, 700487, 700502]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;How will you print student's information together?&lt;/p&gt;

&lt;p&gt;One approach can be to use for loop to print values by index, like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for i in range(len(student_names)):    
    print("ID: {0} name: {1}".format(student_ids[i], student_names[i])) 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;But what if you want the output in the form of a list contains tuples&lt;br&gt;
for each student with its name and ID in it?&lt;/p&gt;

&lt;p&gt;This is where the zip function comes into play !!!&lt;/p&gt;

&lt;p&gt;You can achieve the above-mentioned results easily using the zip&lt;br&gt;
function, list this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;final_result = list(zip(student_ids, student_names))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And that's it! That's all you'll have to do.&lt;/p&gt;

&lt;p&gt;The output of the zip function would look something like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[(700405, 'Alex'), (700465, 'Murphy'), (700487, 'Jinny'), (700502, 'George')]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Isn't that neat !!!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to reverse the effects of zip function?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Although there are various ways to undo the effects of the zip function,&lt;br&gt;
the best approach will be to use the zip function and pass the list with&lt;br&gt;
the * operator to unzip like this&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;list_to_unzip = [(700405, 'Alex'), (700465, 'Murphy'), (700487, 'Jinny'), (700502, 'George')]

unzipped = zip(*list_to_unzip)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The value of unzipped will be like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[(700405, 700465, 700487, 700502), ('Alex', 'Murphy', 'Jinny', 'George')]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I hope this article helped you to understand the working of the zip&lt;br&gt;
function and would add up to your existing knowledge of python.&lt;/p&gt;

&lt;p&gt;In case of any doubts, you can comment down all your queries and I will&lt;br&gt;
try to solve them as soon as possible.&lt;/p&gt;

&lt;p&gt;Also, don't forget to check out my &lt;a href="https://youtube.com/AllAboutPython" rel="noopener noreferrer"&gt;YouTube&lt;br&gt;
Channel&lt;/a&gt; if you liked this article&lt;/p&gt;

&lt;p&gt;With this, it's time for me to go, this is All About Python, signing off&lt;/p&gt;

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