Python List Methods: A Practical Guide to Work with Lists

a-simple-guide-to-methods-and-functions-for-python-lists

A method is a functionality provided by the Python list data type that can be called by specifying the list followed by a dot and followed by the method you want to call. Some examples of methods supported by Python lists are append (adds an item to the end of a list), insert (adds an … Read more

How to Create a Random UUID String in Python

How to Create a Random UUID String in Python

This article will guide you through the process of generating a random UUID (Universally Unique Identifier) string using Python. What is a UUID? A UUID is a 128-bit number you can use to uniquely identify information in computer systems. The term “universally unique identifier” suggests that this ID is unique, which is nearly true, given … Read more

3 Simple Ways to Check If a List is Empty in Python

Check if list is empty using Python

Do you want to know how to check if a list is empty in Python? You are in the right place. Here you will learn three simple ways to do that. To check if a Python list is empty you can use the len() built-in function that returns the number of elements in a list. … Read more

What is the ternary operator in Python?

Ternary Operator in Python

I’ve heard that Python has an operator called ternary operator but I don’t know how to use it. What does the ternary operator do? The Python ternary operator (or conditional expression) works on three operands and allows to write the logic of an if else statement in a single line of code. With the ternary … Read more

Why Strings are Used in Python? [Beginner Tutorial]

Why strings are used in Python?

Strings in Python enable you to work with textual data, which is fundamental in every programming project, whether it’s for data analysis, web development, or automation. Think of strings as a collection of text characters, including letters, numbers, symbols, or spaces. Python strings are immutable, this means you cannot update individual characters in a string … Read more

Basics of Functions in Python: Make Your Code Reusable

Python functions

I have written this article to help you understand how functions can make your life easier when writing a program in Python. The concept of function in Python is the same as in many other programming languages. Functions allow you to organize code in modular blocks and make code reusable. The more your Python code … Read more

How do I check if an item exists in a list with Python?

Does an item exists in a Python list?

To check if a list contains an item in Python, you can use the “in operator”. This operator returns True if the element exists in the list and False otherwise. An alternative is to use the list count() method. Note: The terms item and element of a list used in this article have the same meaning. … Read more

How do I create a list of dictionaries with Python?

Create a list of dictionaries with Python

Imagine you are creating an application in which you have to track multiple users and each user has several properties (e.g. name, surname, and age). You could use a list of dictionaries as a data type to handle this requirement. You can represent the properties related to one user using the following dictionary: To track … Read more

How can I check the availability of a domain with Python?

Check availability of a domain in Python

To check if a domain is available you can call the whois command using Python and then parse the output returned by whois. This check can also be done using the nslookup or dig commands. The most common module to execute commands in Python is subprocess. Below you can see the syntax of the whois … Read more