From the course: Grasshopper and Rhino: Python Scripting

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

For loop

For loop

From the course: Grasshopper and Rhino: Python Scripting

Start my 1-month free trial

For loop

- [Narrator] While scripting with large lists in Grasshopper, we often need to perform a single or set of instructions for every item in the list. Say, for example, we had a list of numbers. We may want to create a list of points or objects based on those numbers. To do this in Python, we need to learn about a programing concept know as looping. Looping allows us to execute an instruction repeatedly until a certain condition is met. Say, for example, we a loop through every item in a list. There are two types of looping in Python: the for loop and the while loop. Let's start by having a look at the for loop. Say, for example, we have a list of numbers zero through to five. A for loop will allow us to iterate or loop over every item in the list and perform an instruction. To do this, we need a temporary variable say, Var for example. However, this could be any variable we like. And for each loop through the list, the item will be temporarily assigned to that variable So looping through…

Contents