Python any: How to Check If Element is Iterable or Not

An iterator is an object that contains the countable number of values. Python iterator is an object that can be iterated upon, meaning that you can traverse through all the values inside an iterator. Python any() Function Python any() is an inbuilt function that returns True if any element of an iterable is True otherwise … Read more

Python Logging: How to Use Logging in Python

Python logging is an inbuilt module that defines functions and classes which implement the flexible event logging system for applications and libraries. The key benefit of having a logging API provided by a standard library module is that all Python modules can participate in the logging, so your application log can include your messages integrated … Read more

How to Remove Character from String in Python

In Python, the string object is immutable and hence sometimes poses visible restrictions while coding the constructs that are required in day-day programming. This article presents the solution of removing the character from the string. We will see different methods and approaches. Remove Character From String In Python To remove a character from a string … Read more

Python hash: How to Create Hash Value in Python

A good hash function is the one function that results in the least number of collisions, meaning, No two sets of information should have the same hash values. Python hash() Python hash() is a built-in method that returns a hash value of the object if it has one. Hash values are just integers, which are … Read more

Python Random Number Module Example

Python Random is an inbuilt number module that can generate pseudo-random numbers. The function random() generates the random number between 0 and 1 [0, 0.1 .. 1]. Numbers generated with the random module are not truly random, but they are enough random for most purposes. Python Random Number Module Python random module has various functions to … Read more

Python Enumerate: How to Use enumerate() Function

You can convert enumerate objects to list and tuple using the list() and tuple() method respectively. A lot of times when we are dealing with the iterators, we also get to keep the count of iterations. Python eases the programmers’ task by providing an inbuilt function enumerate() for this task. Python Enumerate Function Python enumerate() … Read more

Python Requests: How to Send Network Request in Python

What is HTTP? An HTTP is a set of protocols to enable communication between clients and servers. It works as a request-response protocol between a client and the server. The web browser may be the client, and an application on a remote computer that hosts a website may be the server. Python Requests Python requests … Read more

Python eval: How to Use eval() Function in Python

Python eval() method runs the python code, which is passed as an argument within the program. The eval() method returns the result evaluated from the expression. Python eval() Python eval() is an inbuilt function that parses the expression passed to that function and runs python expression(code) within the program. Syntax The syntax of the eval() … Read more

Python Generators: How to Create Iterators using Yield

There is a lot of things in building iterators in Python; we have to implement a class with __iter__() and __next__() method, keep track of internal variable states, raise StopIteration when there were no values to be returned, etc. Python Generators Python generators are used to create the iterators, but with a different approach. Generators are simple functions that … Read more

Python String Count: How to Count Substrings in Python

The count() is a built-in function in Python that returns you the count of a given element in a list or a string. Python String count() Python string count() is an inbuilt function that returns the number of occurrences of the substring in the given string. The count() method searches the substring in the given string and returns how many times … Read more