Tag: Ways]
Python: How to convert integer to string (5 Ways)
In this article we will discuss 5 different ways to convert a integer to string in python. Using str() to convert an int to string in python Python provides a function str(object). It accepts an object as an argument and returns a string representation of that object. So, if we pass the an integer as …
Python: Remove characters from string by regex & 4 other ways
In this article we will discuss different ways to delete single or multiple characters from string in python either by using regex() or translate() or replace() or join() or filter(). Remove characters from string using regex Python’s regex module provides a function sub() i.e. Advertisements re.sub(pattern, repl, string, count=0, flags=0) It returns a new string. …
Python: Remove characters from string by regex & 4 other waysRead More
Python: Check if a value exists in the dictionary (3 Ways)
In this article we will discuss different ways to check if a value exists in a dictionary or not. We will cover the following ways, Subscribe Table Of Contents Check if value exist in dict using values() & if-in statement Check if a value exists in python dictionary using for loop Check if a value …
Python: Check if a value exists in the dictionary (3 Ways)Read More
R: Find the index of an element in the vector ( 4 ways )
Often, we have a requirement to find out the index of the first occurrence of an element in the vector so that some operations can be performed on the same. There are many ways to do the same in R; we will go through a few of them. Let us take a simple example where …
R: Find the index of an element in the vector ( 4 ways )Read More
Python: Remove first element from a list (5 Ways)
This article will discuss different ways to delete the first element from a list in Python. Table of Contents Remove the first element from a list in Python using the pop() function Remove the first element from a list in Python using slicing Remove the first element from a list in Python using del keyword …
Creating Vectors in R Programming (6 ways)
Vectors are fundamental data structures in R with logical, integer, double, character, and raw data types. Vectors are somewhat similar to what is arrays in C. In this article, we will be learning how to create vectors in R using some primary ways: using c() function. using ‘:’ using rep() function using vector() function using …
C++: Convert Array to Vector (7 Ways)
In this article, we will discuss different ways to convert an array to a vector in C++. Table of Contents Convert an array into a vector in C++ using Range Based Constructor. Convert an array into a vector in C++ – begin() / end(). Create an empty vector in C++ and add array elements to …
C++: Print a vector in reverse order (5 Ways)
In this article, we will discuss different ways to print the contents of a vector in reverse order. Table of Contents C++: Print all items of vector in reverse order using reverse iterator C++: Print all items of a vector in reverse order using indexing C++: Print all elements of a vector in reverse order …
C++: Convert vector to array (4 Ways)
In this article we will discuss different ways to convert a vector into an array in C++. Convert a vector into an array by copying items one by one Suppose we have a vector of N integers and we want to create an array from it. For that first we need to create a n …
C++: Convert Vector to Set ( 5 Ways )
In this article, we will discuss different ways to convert a vector into a set in C++. Convert a Vector to a Set in C++ using Range Based Constructor In C++, set class provides a constructor which accepts a range i.e. [start, end). It creates a set from all the element in the given range …