How to split a string in python?

wondering how to split a string in python? Python has in-built function split that splits a string. Split Function By default python split function splits string by space and returns list of splitted string. Example str=”Once upon a time” print(str.split(” “)) Output: [“Once”,”upon”,”a”,”time”] Similarly we can pass any separator we want. Example str=”once-upon-a-time” print(str.split(“-“)) Output: […]

How to reverse a string in python?

In certain situation, you may want to reverse the string using Python programming language. Following is the right way to do it. Reverse a string in python In python, there is no in built function available which can reverse a string. However we can use slice in backwards to print the string in the reverse. […]

PHP: Remove Space at the end of string

There is a string that ends with a single white space. You can use PHP trim function to remove the white space at the end of the string. PHP trim() Function This function not only removes white space at the end of the string but also at the beginning of the string. <?php echo $username; […]

PHP Error Types

While coding, or developing a PHP website or even in production stage, a website encounters. These errors could be result of wrong coding, mistake in the code, wrong implementation of code or any similar reason. PHP has list of errors that occur in a web project. PHP Error Types Parse Error Parse Error also known […]

PHP Constants

Constants are used in a PHP project whose value never changes. Such values can be defined as constant variables. The only important point we need to remember, PHP Constant variable values can not be overwritten.Such variables are defined once and remains same as long as website exists. PHP Constant PHP constant can be defined using […]

PHP Super Global Variables

PHP has provided predefined variables which are called super globarl variables. In a PHP website project, there might be situation to store logged in user information, access web url info and server related data. In such cases, super global variables are useful. PHP Super Global Variables There are nine types of Super Global Variables exist […]

Install PHP in Apache Server Ubuntu 20.04

PHP installation in Apache server is easy. If you are Ubuntu 20.04 operating system in your cloud hosting, then following step by step guide is going to help you to install PHP. PHP Installation Installing PHP only is not sufficient to run a web application which has PHP as server side scripting. We need libapache2 […]

Install MySQL in Ubuntu 20.04 Apache Server

MySQL server is essential to maintain a database for web application. MySQL is best suitable for relational database management system projects. Following article is going to guide you to insall MySQL in Apache server(Ubuntu 20.04 version) MySQL Installation First of all, login with your non root username and password with super user privileges.(If you have […]

Setup Firewall in Ubuntu 20.04 Server

Firewall is important in any server setup. It helps to allow required network traffic and restricts rest. Most importantly if firewall is not set correctly then it would open doors for the hackers. Following tutorial on setting up firewall in Ubuntu 20.04 Server is helpful to set it right. Login with your user name and […]

Introduction to Web Hosting

Web Hosting is essential for every web application. And if you are confused to decide which hosting is suitable for your project? Then, this step by step complete article is going to put light on web hosting in detail. At the end of this article you will be completely aware about the right hosting option […]

PHP MySQLi Delete Record

So far, I have discussed about connection establishment, create table, insert record, read records (select statement), update record. In this article we are going to learn about delete a record. Following is the table which I am going to delete a record. This table name is emp_info emp_id emp_name emp_age 1 Raj 22 2 Rahul […]

PHP MySQLi Update Records

In some cases, we may want to update table data using update sql statement. Lets see how can we update. The table which I am using to update record is as below. The table name is emp_info emp_id emp_name emp_age 1 Raj 22 2 Rahul 24 3 Vivek 26 4 Ajay 28 5 Suraj 29 […]

PHP MySQLi Read Records (Select Statement)

So far we have learned how to establish connection with mysql database using mysqli, create table, insert record. In this tutorial, we are going to learn how to print records from the table. For this we are going to use sql select statement. The table from which I am going to fetch record is as […]

PHP MySQLi Insert Record

In previous tutorial, we have learned how to create a table using mysqli and php. In this article we are going to learn how to insert record into table. For reference look at the below table. emp_id emp_name emp_age 1 Raj 22 2 Rahul 24 3 Vivek 26 4 Ajay 28 5 Suraj 29 In […]

PHP MySQLi Create Table

The first job, in php database project can be creating a table. In this article, we will learn how to create a table in mysql database using php and mysqli. (See following table example) emp_id emp_name emp_age 1 Raj 22 2 Rahul 24 3 Vivek 26 4 Ajay 28 5 Suraj 29 Lets see how […]

PHP MySQLi Establish Connection

In this first article of PHP MySQLi Tutorial, we are going to learn how to establish database connection with mysql database. Before proceeding further, you must have following knowledge Basics of PHP MySQL commands (create table, insert row, select row, update row, delete row etc.) What is MySQLi? MySQLi is a php based library which […]

Python PyMySQL delete record

So far, I have discussed about connection establishment, create table, insert record, read records (select statement), update record. In this article we are going to learn about delete a record. Following is the table which I am going to delete a record. the table name is emp_info emp_id emp_name emp_age 1 Raj 22 2 Rahul […]

Python PyMySQL Update Record

In some cases, we may want to update table data using update sql statement. Lets see how can we update. The table which I am using to update record is as below. emp_id emp_name emp_age 1 Raj 22 2 Rahul 24 3 Vivek 26 4 Ajay 28 5 Suraj 29 In the above table, lets […]

Python PyMySQL Create Table

The first job, in python database project can be creating a table. In this article, we will learn how to create a table in mysql database using python and pymysql. (See following table example) emp_id emp_name emp_age 1 Raj 22 2 Rahul 24 3 Vivek 26 4 Ajay 28 5 Suraj 29 Lets see how […]

Python PyMySQL Establish Connection

In this first article of Python PyMySQL Tutorial, we are going to learn how to establish database connection with mysql database. Before proceeding further, you must have following knowledge Basics of Python MySQL commands (create table, insert row, select row, update row, delete row etc.) To establish connection with a database like MYSQL server, we […]

Python how to check if list contains element?

In python, we can check if a list contains certain element. For this “in” keyword is helpful. Example selected_candidates=[“rahul”,”ajay”,”vijay”] #check if raju is present in the list if “raju” in selected_candidates: print(“Raju has been selected for the job”) else: print(“Raju has been disqualified for the job”) Output: Raju has been disqualified for the job.

Read html file in python beautifulsoup

Beautifulsoup is a powerful library that helps scrape complex to complex html website easily. Python+Requests+Beautifulsoup=Successful Web Scraping Read html file in python beautifulsoup To use beautifulsoup library, this library must be present in the system. If you are using pycharm, then go to file then project settings and install bs4. bs4 contains beautifulsoup library. Following […]

Python How to make a dictionary from two lists?

We have two lists. And we want to create a dictionary combining values of these two lists. In such case, we can create a dictionary from two lists as following way. Example name_list=[“rahul”,”vijay”,”ajay”] phone_list=[“1111″,”2222″,”3333”] #declare an empty dictionary phone_book={} for idnum in range(0,len(name_list)): phone_book.add(name_list[idnum],phone_list[idnum]) #lets print the dictionary print(phone_book) Output: { “rahul”:”1111″, “vijay”:”2222″ “ajay”:”3333″ } […]

Python how to check if string contains substring?

In certain situation, you may want to know whether a sting contains another sub-string. Then the helpful tool that eases the process of knowing this is, “in” keyword. It checks whether the supplied element is present in the target element or not. If element is present then it would return true otherwise it would return […]

How to make python print something multiple times?

Python has print function which prints the passed argument. And in some cases we may want to print a message multiple times. If we want to print something multiple times then for loop is an easy option. for _ in range(0,10): print(“hello friend”) Output: hello friend hello friend hello friend hello friend hello friend hello […]

Check if a python string contains a character

In some cases we may want to check if string contains a certain character. To do check presence of a character in a string in python, we can use the in keyword functionality. If element is present then it would return true other wise it would return false. Example sentence=”Orange is not apple” #lets check […]

Connect MS Access database in python (pyodbc)

MS access is also used as database to store and update data. In python projects we can use ms access as database and for that pyodbc library is required. Install pyodbc library Assuming you have prior known of python and library installation, run the following command in your terminal or command prompt. pip install pyodbc […]

How to select li element in selenium python?

In certain cases we may want to fetch data from list by using Selenium in Python. The simplest solution to target any element by its tag name is to use find_element_by_tag_name. Note: Selenium Python has similar function find_elements_by_tag_name. Do not use this one. It returns a list of targeted element. Select li element in selenium […]

How to launch Internet Explorer IE browser in selenium python?

Assuming you have prior knowledge of Python and Selenium, following are the step by step guideline to launch Internet Explorer browser in Selenium Python. To run internet explorer browser from selenium python, you must have to have internet explorer driver available in your system. You can download it from selenium’s official website. Selenium Official Website: […]

How to add new python interpreter in pycharm?

In mac OS and Linux OS, python older version is pre-installed. So if we run pycharm, then by default pycharm picks older version of python which is 2.7. But we want the latest version 3.0 as interpreter in pycharm. So following is the solution to add new python interpreter in pycharm. Open pycharm and launch […]