What does next function do in loops?
MACHINE LEARNING RECIPES DATA CLEANING PYTHON DATA MUNGING PANDAS CHEATSHEET     ALL TAGS

# What does next function do in loops?

This recipe explains what does next function do in loops

## Recipe Objective

What does the next function do in loops ? Loops are used to execute a particular block of code for a specified number of time for a given condition. If the user wants to skip the current iteration in a loop and jump to the next iteration without terminating out of the loop, the next () function can be used. next function can be used inside a for loop as well as in a while loop. This recipe demonstrates an example of the next function using a for loop.

## Step 1 - Create a vector

``` a <- c(1:10) ```

## Step 2 - Using next()

Once the for loop begins , and the next function is found, the next() skips that iteration and jumps to the next iteration.

``` for (i in a) { if (i==3) { print("skip this and next",i) next } print(i) } ```
```"Output of the code is :"
1
2
"skip this and next"
4
5
6
7
8
9
10
```

#### Relevant Projects

##### Census Income Data Set Project - Predict Adult Census Income
Use the Adult Income dataset to predict whether income exceeds 50K yr based on census data.

##### Ensemble Machine Learning Project - All State Insurance Claims Severity Prediction
In this ensemble machine learning project, we will predict what kind of claims an insurance company will get. This is implemented in python using ensemble machine learning algorithms.

##### Build a Music Recommendation Algorithm using KKBox's Dataset
Music Recommendation Project using Machine Learning - Use the KKBox dataset to predict the chances of a user listening to a song again after their very first noticeable listening event.

##### Data Science Project - Instacart Market Basket Analysis
Data Science Project - Build a recommendation engine which will predict the products to be purchased by an Instacart consumer again.

##### Predict Employee Computer Access Needs in Python
Data Science Project in Python- Given his or her job role, predict employee access needs using amazon employee database.

##### Predict Credit Default | Give Me Some Credit Kaggle
In this data science project, you will predict borrowers chance of defaulting on credit loans by building a credit score prediction model.

##### Machine learning for Retail Price Recommendation with Python
Use the Mercari Dataset with dynamic pricing to build a price recommendation algorithm using machine learning in Python to automatically suggest the right product prices.

##### Data Science Project on Wine Quality Prediction in R
In this R data science project, we will explore wine dataset to assess red wine quality. The objective of this data science project is to explore which chemical properties will influence the quality of red wines.

##### Learn to prepare data for your next machine learning project
Text data requires special preparation before you can start using it for any machine learning project.In this ML project, you will learn about applying Machine Learning models to create classifiers and learn how to make sense of textual data.

##### Digit Recognition using CNN for MNIST Dataset in Python
In this deep learning project, you will build a convolutional neural network using MNIST dataset for handwritten digit recognition.