From the course: Learning ArcGIS Python Scripting
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Use loops to work with lists - ArcGIS Pro Tutorial
From the course: Learning ArcGIS Python Scripting
Use loops to work with lists
- [Instructor] When you have a list of data that you want to run some code on, you can use a loop to step through that list and process each element one by one. A loop lets you execute a set of code over and over. For example, you can do something to all the feature classes in a geo database, or all the layers in a map, or all the text files in a folder. Loop blocks start with a specific line of code, for or while, and that line has to end with a colon. The next line and all the lines that are a part of that loop block, must be indented. It's the indention that determines what is a part of the loop. You end the loop by moving the next line of code back to the margin with no indention. So in this case, in this little example, the word "for" begins the loop and the line ends with a colon. And then the next two lines, the print and the count statement are both a part of the for loop, so they're repeated over and over again. But the final print statement, it's pulled back and lined up…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Working with lists6m 18s
-
(Locked)
List methods and functions8m 48s
-
(Locked)
Use loops to work with lists7m 50s
-
(Locked)
Write a script using list methods and a for-loop3m 39s
-
(Locked)
Nested loops8m 16s
-
(Locked)
Conditional statements7m 35s
-
(Locked)
Write a script using ArcGIS API10m 31s
-
(Locked)
Getting to the properties of GIS data with Describe3m 28s
-
(Locked)
Challenge: Properties of layers37s
-
(Locked)
Solution: Properties of layers3m 4s
-
(Locked)
-
-
-
-