You are usually asked to get the largest or smallest element in a list, but it can also be the case that you are asked to also find more than just a single element, namely, a number of elements that are the largest, or the smallest in that list.
Continue readingCategory: Science & Tech (Page 12 of 35)
Most of the time you are adding elements into a list, or set, or a dictionary. However, there can also be cases when you just need to remove elements. Maybe a particular element, or even all elements at once.
If that is the case, then there is a quick method in Python that you can use to do that.
Continue readingIf you have already tried printing a statement in Python, you have probably seen that you are going to get a new line after you execute it.
Let’s see a quick example:
Continue readingIn 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 have the following list:
We want to see whether we have earned more than 4000 in at least 1 month.
Continue readingThere 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:
Continue readingLooping 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:
Continue readingThere 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 it can be less frequent when you need to find the second largest one, or the second smallest element. The less demand for it in our daily work, the less supply with tutorials on how to do it.
Continue readingThis 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.
Continue readingThere 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.
Continue readingTuples 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:
Continue reading