Tag: Loop
For loop with 2 variables in C++ and Java
In this article we will discuss how to use for loop with two variables. For loop is basic feature we use in programming. In it we use a variable and keep on increasing or decreasing it till a condition is matched. Advertisements But many times a scenario comes where we want to increment or decrement two variables …
c++11 unordered_map : erase elements while iterating in a loop
In this article we will discuss how to erase multiple elements from an unordered_map based on some condition and while iterating. Erasing Multiple elements from unordered_map while iterating Suppose we have an unordered_map of string and integers as key value pairs i.e. Advertisements First : 1 Second : 2 Third : 3 Fourth :  4 Fifth : 5 …
c++11 unordered_map : erase elements while iterating in a loopRead More
Python: Iterate / Loop over Dictionary (All key-value pairs)
In this article we will discuss different ways to iterate over all key-value pairs of a dictionary. Table of Contents: Iterate over a dictionary using for loop over keys Iterate over key-value pairs of dictionary using dict.items() Iterate over a dictionary using list comprehension Iterate over specific key-value pairs of dictionary Suppose we have a …
Python: Iterate / Loop over Dictionary (All key-value pairs)Read More
Pandas : Loop or Iterate over all or certain columns of a dataframe
In this article we will different ways to iterate over all or certain columns of a Dataframe. Let’s first create a Dataframe i.e. # List of Tuples empoyees = [(‘jack’, 34, ‘Sydney’) , (‘Riti’, 31, ‘Delhi’) , (‘Aadi’, 16, ‘New York’) , (‘Mohit’, 32,’Delhi’) , ] # Create a DataFrame object empDfObj = pd.DataFrame(empoyees, columns=[‘Name’, …
Pandas : Loop or Iterate over all or certain columns of a dataframeRead More
Python: For Loop – Explained with examples
In this article, we will learn the syntax and usage details of for loop in python. Then we will look at various examples of the for loop. In python, we can iterate over a group of statements multiple times using a for loop. But the number of times these statements will be executed by a …
Python: while loop – Explained with examples
In this article, we will learn the syntax and usage of a while loop in python. Need of a while loop? In python, if we write some statements like this, Advertisements print(‘First line’) print(‘Sample text’) print(‘Last line’) The interpreter will execute these statements in sequential order, but only once from top to bottom. What if …
C++: Iterate or Loop over a Vector
In this article, we will discuss different ways to iterate over a vector in C++. Watch different ways to iterate or loop over a Vector in C++. Iterate over a vector in C++ using range based for loops Range based for loops were introduced in C++11. It helps to loop over a container in more …
Python: Loop / Iterate over all keys of Dictionary
In this article, we will discuss different ways to iterate over all keys of a python dictionary. Table of Contents Loop over all keys of dictionary using for loop. Loop over all keys of dictionary using keys(). Loop over all keys of dictionary using items(). Loop over all keys of dictionary using for loop A …
Loop / Iterate over all values of dictionary in Python
In this article, we will discuss different ways to iterate over all values of a python dictionary. Table of Contents Loop over all values of dictionary using values(). Loop over all values of dictionary using for loop. Loop over all values of dictionary using items(). Loop over all values of dictionary using values() In python, …
Loop / Iterate over all values of dictionary in PythonRead More
MySQL For Loop Example
In this article, we will go through a few examples of For Loop in MySQL. Like other languages, MySQL also provides LOOP functionality to execute one or more statements multiple times. The statements within the loop repeat until the LOOP gets terminated. Table of Contents Advertisements MySQL For Loop Syntax MySQL For Loop Examples MySQL …