From the course: Learning ArcGIS Python Scripting (2018)

Unlock the full course today

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

Conditional statements

Conditional statements - ArcGIS Tutorial

From the course: Learning ArcGIS Python Scripting (2018)

Start my 1-month free trial

Conditional statements

- [Instructor] Sometimes you need your Python script to stop and make a decision before moving on. For example, suppose you write a Python script that's gonna run the erase geoprocessing tool, which requires at least a standard ArcMap license. How do you check to see if the user has at least a standard license? You use a conditional statement, an if statement. If statements let you control the flow of your script. For example, suppose your script asks the user for a road name, and then it checks to see if a road name was entered. Did you get a value from them? Yes? Okay, try and select the road. No? Ask them to enter it again. The syntax for an if statement looks like this if some condition is true do something. There's a colon at the end of the first line. So if some condition is true do something, else, do something else. To make comparisons in an if statement, you'll need some comparison operators. To compare if two values are equal you use a double equal sign. A single equal sign…

Contents