In the previous article, we saw how to check whether all the values in an iterable object are True in Python.
In this article, we are going to see whether there is at least one condition that is satisfied in an iterable object in Python.
Let us suppose that we…
There is a quick way to check whether all the values in an iterable object are True or not in Python.
Let us suppose that we have the following list and we want to check whether all the values in it are True:
One way to check it would…
One of the main ways that you are used to do comparisons in a programming language is the following:
a < b
Now, if you need to do a comparison with a third variable, it gets a bit clunky:
a <c AND c < b
Yes, it does work like…
Looping through a list in Python is quite straightforward.
Let us mention two ways that you can do it.
You can do it using indexes and the length of the list, like the following:
We can also do that by simply iterating through the list:
Now if we…
There are many articles and videos that show you how to find the largest in a list. However, there are not that many articles that show you how to find the second largest element in a list or the second smallest element in a list.
Yes, I also agree that…
This is another quick article in which we are going to see how to do a conversion of a string into a list of characters in a single line in Python.
Let us take an example of a string that we want to convert into a list:
There are a lot of built-in methods that you can use to do a lot of manipulations with strings in Python.
You can convert them into lists, convert them from one case to another, or split them into partitions.
One such method is the opportunity to partition strings.
Tuples represent an immutable data structure that can be used to store an ordered sequence of data.
Once you initialize them, you cannot change their values.
Let’s see an example of a tuple:
Since it can be quite challenging to keep track of each of the elements in a…
If you have solved some sort of coding challenges online that have to do with lists, you know that you usually need to have access to indices and also elements in it.
You may also have to do that while you are working on your tasks.
Let us assume that…
Working with a list in Python can be one of the most common tasks.
However, not everything comes to you in the form of a list as input.
There can be times when you are interacting with an external API, or reading from a legacy database, or formatting the data…