Tag: Empty
Python: Check if string is empty or blank or contain spaces only
In this article we will discuss different ways to check if a given string is either empty or contains only spaces. Check if a string is empty using len() len() function in python accepts a sequence as an argument and returns the number of elements in that sequence. So, if we pass a string as …
Python: Check if string is empty or blank or contain spaces onlyRead More
Python: Check if any string is empty in a list?
In this article we will discuss different ways to check if a list contains any empty or blank string in python. Use any() and List Comprehension to check if list contains any empty string We have created a function to check if a string is empty. It will also consider a string empty if it …
R: Create empty vectors and add new items to it
Empty vectors in R are the vectors of length zero. We often need to create empty vectors in a program so that elements can be added later as and when required. While there are several ways to do the same, we will be talking about few of them. In this article will learn how to …
Creating Empty Matrix in R
Many times, we need an empty matrix and want to fill it later as per our requirement. Below are a few examples to achieve the same.In this article, we will be looking into creating an empty matrix in R and in the final section we will see how to verify if an object is a …
Python: Check if dictionary is empty
In this article we will discuss different ways to check if a dictionary is empty or not. These two ways to check if a python dictionary is empty or not, By casting dictionary to bool in if statement. Using len() function. Suppose we have two dictionaries: The first dictionary contains strings as keys and integers …
Javascript: Check if string is empty (6 ways)
This article will see how to check if a string is empty using different methods and various examples. Table of Contents:- Javascript check if string is empty using === operator Javascript check if string is empty using length and ! operator Javascript check if string is empty or has only white spaces Javascript check if …
Javascript: Check if an array is empty
While working with arrays in javascript, often there is a requirement to check if an array is empty or not. This article will describe how to check if an array is empty or exists in javascript. Table of Contents:- Check if an array is empty using isArray() and length property Check if an array is …
Add key-value pairs to an empty dictionary in Python
This article will discuss different ways to add key-value pairs to an empty dictionary in python, like using [] operator, update() function or dictionary comprehension. Add key-value pairs to an empty dictionary using [] operator Suppose we have an empty dictionary like this, # Creating an empty dictionary sample_dict = {} To add a new …
Add key-value pairs to an empty dictionary in PythonRead More
Javascript: Check If an Object Empty
While working in javascript, we often encounter a requirement to determine if the object is empty. This check is required at times before operating on the properties or methods of the objects. This article discusses various ways to check if an object is empty using example illustrations. Javascript objects are something that describes anything with …
Check if String is Empty in C++
In this article, we will discuss different ways to check if a string is empty or not in C++. Table of Contents Check if String is Empty in C++ using string::empty() Check if String is Empty in C++ using string::size() Check if String is Empty in C++ using string::length() Check if String is Empty in …