If you are getting started with Python one of the topics you will encounter soon are functions. Here is how you can start using them.

Python functions allow to make your code more readable and reusable. A function is a block of code that performs a specific operation or returns a specific result. Once you define a function you can simply call it over and over in your code without having to rewrite that code again.

We will start by looking at how to define a function and then section after section we will keep building on the concepts you…

Are you considering learning coding and are you thinking about Python as a language? In this article I will answer some of the burning questions you might have.

Learning Python coding is one of the top skills in today’s IT industry. That’s because the Python programming language can be used for several purposes. You can use it to create web applications, APIs, standalone applications, artificial intelligence (AI) applications, scripts, videogames and much more.

Do you want to be able to start coding fast and build a skill that will make you valuable in today’s market? It’s time to learn Python.

The tuple is a basic Python data type. It’s important to understand it and to know how to use it. This tutorial will help you with that.

Python tuples are used to store an ordered sequence of values. Tuples are immutable, this means that the values in a tuple cannot be changed once the tuple is defined. The values in a tuple are comma-separated and they are surrounded by parentheses.

You will see some examples that clarify how you can use tuples in your programs and why.

Let’s start exploring the world of tuples!

How Do You Make a Tuple in Python?

To create a new tuple you…

If you haven’t used the Python zip() function yet this is an opportunity to look at how it works and how you can use it in your programs.

The Python zip() function takes as input multiple iterables and returns an iterator of tuples where the n-th tuple contains the n-th element from every iterable. The zip function can also be applied to iterable of different length and in that case it stops when the smallest iterable is exhausted.

We will go through some example to see how to apply the zip function to multiple Python data types.

Let’s zip them…

Printing even and odd numbers from a Python list is a good exercise if you are getting started with Python and you want to learn its basics.

To extract even and odd numbers from a Python list, you can use a for loop and the Python modulo operator. A second option is to replace the for loop with a list comprehension. The extended syntax of the slice operator also allows us to do that with one line of code but only when you have lists of consecutive numbers.

We will go through few examples in this tutorial and the point…

In your Python program you might want to validate an IP address. This can be a requirement if you write OS level programs and not only.

To validate an IP address using Python you can use the ip_address() function of the ipaddress module. This works both for IPv4 and IPv6 addresses. You can also validate an IP address by using a custom function or a regular expression that verify the sets of numbers an IP address is made of.

Let the validation begin!

How Do I Validate an IP Address in Python?

The simplest way to validate if a string represents an IP address is by using the Python…

Getting every other element from a Python list might seem easy to do but it actually requires some knowledge of Python basics.

To get every other element in a Python list you can use the slice operator and use the fact that this operator allows providing a step argument (with its extended syntax). Another approach is to use the mathematical concept of the remainder and apply it to list indexes.

Let’s get creative and come up with multiple ways to solve this problem!

How Do I Show Every Other Element in a Python List?

Firstly, let’s create a list of strings…

>>> countries = ['Italy', 'United Kingdom', 'Germany', 'United States', 'France']

Are you wondering how to remove spaces from a string in Python? You are in the right place, keep reading, you will know how to do it quickly.

There are multiple ways to remove spaces from a Python string. The simplest approach is to use the string replace() method. If the spaces to remove are just at the beginning and at the end of the string the strip() method also works fine. An alternative approach is to use a regular expression.

We will start with the approach that works in most cases and then look at other options to give…

Knowing how to reverse a Python string is basic knowledge you should have as Python developer. This can also apply to other data types.

Python does not provide a built-in function to reverse the characters in a string. To reverse a string in Python you can use the slice operator with the syntax [::-1]. You can also use the reversed() function together with the string join() function.

Let’s go through some examples that show you how to approach this in practice.

How Do You Reverse a String in Python?

I want to give you the solution to the problem first, then we will understand how this solution exactly…

Do you know how to check if two strings are anagrams of each other in Python? It’s a common problem and there are multiple ways to solve it.

Two strings are anagrams of each other if they both contain the same characters and each character is present in each string the same number of times. Two ways to check if two strings are anagrams in Python is by using the sorted() function or the collections.Counter() function.

Technically anagrams should have a meaning but in this scenario we will consider as anagrams also permutations of characters without meaning.

Let the anagrams…

Claudio Sabato

I’m a Tech Lead, Software Engineer and Programming Coach. I want to help you in your journey to become a Super Developer!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store