python Articles

Get all python tutorials here

Solve "No Such File or Directory" Error in Python

Solve "No Such File or Directory" Error in Python

In python, you might come across "No Such File and Directory" error. Learn about the causes and get the step-by-step solution with examples.

Read More
How to round down a number in python

How to round down a number in python

Learn how to round down in Python with step-by-step examples using floor division and the math.floor(), int(), and math.trunc() function to perform mathematical calculation.

Read More
Understanding the Inline If Statement in Python

Understanding the Inline If Statement in Python

Learn what is an Inline If statement and how to use it in a python program and also learn about the use cases of it with some examples

Read More
Line continuation | Long statement in Multiple lines in Python

Line continuation | Long statement in Multiple lines in Python

Find out how to write long strings that continue to the next line using python. And to solve line continuation in python.

Read More
Find Length of Dictionary in Python with Examples

Find Length of Dictionary in Python with Examples

To find the length of the dictionary we have to use the `len()` function in python. It returns the number of keys in the dictionary.

Read More
Reverse an Array in Python (Using Numpy And Array Module)

Reverse an Array in Python (Using Numpy And Array Module)

We have to create an array in Python using numpy and array module and use reverse() and slicing method to reverse it.

Read More
Python import from parent directory

Python import from parent directory

We can import methods from a parent directory in python using the sys.path.append() and sys.path.insert() method of the sys and os modules.

Read More
FileNotFoundError: No such file or directory Error Python

FileNotFoundError: No such file or directory Error Python

Find out how to solve the no such file and directory error by specifying the absolute and relative path of the file in python.

Read More
Save Python dict as JSON: Convert Dictionary to JSON

Save Python dict as JSON: Convert Dictionary to JSON

Find out how to convert dictionary to JSON format using python. In python, we can use the json.dumps() method to covert the dict to json object.

Read More
Find square root of negative number using python

Find square root of negative number using python

We can get the square root of a negative number in python using the cmath python library. It provides us various functions to work with complex numbers.

Read More
Square a number in Python (3 ways)

Square a number in Python (3 ways)

Find out how to find the square of a number in python. Python programs to find the square number of list and arrays using python.

Read More
Convert a string to Array (List) in Python(3 ways)

Convert a string to Array (List) in Python(3 ways)

Find out three different ways to convert a string into an array (list) in python.

Read More
How to flatten nested list in python (5 ways)

How to flatten nested list in python (5 ways)

A python list can be 2D list or multi-dimensional list. Find out different ways to flatten a list of list (nested list) in python.

Read More
Prepend List in Python (Append at the beginning)

Prepend List in Python (Append at the beginning)

Find out different ways to prepend list in python. Ways to add items at the beginning of the list in python.

Read More
Create Directory if not Exists in Python

Create Directory if not Exists in Python

To create a directory if the targeted directory does not exist in python we have to use the os.path.exists() method of the os module.

Read More
Sort List or Dictionary by two keys in Python

Sort List or Dictionary by two keys in Python

Learn to sort list, dictionary, tuples with multiple elements in python. Here, we have sort python list and dictionary by two keys.

Read More
How to reverse a range in python | Reverse Range

How to reverse a range in python | Reverse Range

Find out different ways to reverse a range in python using reversed function, negative step and sorted function.

Read More
Python string append | How to Append String in Python

Python string append | How to Append String in Python

Find out different ways to append one string to another in Python using += operator, join function or the f-string method.

Read More
(Solution) ValueError: math domain error in Python

(Solution) ValueError: math domain error in Python

Find out how to solve math domain error while using sqrt, acos, and log of a number in python. Also find the solution of this math error.

Read More
Python Bitwise XOR Operator and its Uses

Python Bitwise XOR Operator and its Uses

The XOR operator or binary operator is use to perform bitwise calculations on integers and boolean values in python.

Read More
Python - Remove Newline From Strings (3 Ways)

Python - Remove Newline From Strings (3 Ways)

We can remove new line from a string using replace(), strip() and re.sub() method in python.

Read More
Check for prime number using for and while loop in Python

Check for prime number using for and while loop in Python

Write python programs to find prime numbers using for loop and while loop and also within a given range between 1 to 100.

Read More
Merge two dictionaries together using python (3 ways)

Merge two dictionaries together using python (3 ways)

Find out 3 different ways to merge or combime two or more dictionaries in python.

Read More
Merge multiple JSON objects into one single object in Python

Merge multiple JSON objects into one single object in Python

Combine multiple JSON objects from a file into a single object and then save it in a file in python.

Read More
Python - Check if list is empty or not

Python - Check if list is empty or not

To check if a list is empty or not, we have to use the len(), bool() and not operator method in python.

Read More
Python-Check if user input is a number

Python-Check if user input is a number

Find out if the user input is a number or string using isnumeric and isdigit methods in Python program.

Read More
Check if user input is empty in python

Check if user input is empty in python

Find out how to check if the user input is empty in python using if and while statement and not operator.

Read More
How to take input as int (integer) in python?

How to take input as int (integer) in python?

Find out how to take integer input in python using int() function with exception handling for errors.

Read More
Remove the Last N element from a List in Python

Remove the Last N element from a List in Python

Find out how to remove the last N element from a Python list using pop(), list slicing and del function.

Read More
Remove Duplicates from List in Python

Remove Duplicates from List in Python

Find out how to remove duplicate items from a list in python using different method and create a unique list.

Read More
Python - Check if a string is Empty or Not

Python - Check if a string is Empty or Not

To find if a string is empty of not in python, we can use len(), not operator ,and strip() or isspace() method to check for non-zero length string.

Read More
Get the Index or Position of Item in List in Python

Get the Index or Position of Item in List in Python

In this post, we will discuss how to find the index of an element from a List in python with some examples.

Read More
Replace character in String by index in Python

Replace character in String by index in Python

Short article on how to replace a character in a string using the index with the help of python code.

Read More
How to replace characters in a string in Python

How to replace characters in a string in Python

Find out how to find and replace characters in a string in Python using Python.replace() method.

Read More
Split string by whitespace in python

Split string by whitespace in python

Find out how to split a string by whitespace using split() method in python. The split method split a string and returns a list.

Read More
How to split a list into multiple list using python

How to split a list into multiple list using python

To split a list we have to find the len of the list and then divide it by 2 to find the middle index. It helps to split list by chunks size.

Read More
Split String and get the first element using python

Split String and get the first element using python

Find out how to split a string and get the first element from the list using maxsplit argument in python.

Read More
Get the current year, month and day in Python

Get the current year, month and day in Python

Find out how to get the current year, month, and day in python. To get the current day or year we use the date class from the datetime module.

Read More
Convert a string into integer or float using Python

Convert a string into integer or float using Python

Find out how to convert a string into an integer or floating point number using int() and float() function in Python.

Read More