# Select IP Address from List

**URL:** <https://forum.inductiveautomation.com/t/select-ip-address-from-list/45630>\
**Category:** Ignition\
**Created:** [April 15, 2021, 12:19pm UTC](https://forum.inductiveautomation.com/t/select-ip-address-from-list/45630 "2021-04-15T12:19:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nruimveld](https://avatars.discourse-cdn.com/v4/letter/n/8797f3/32.png) [@nruimveld](https://forum.inductiveautomation.com/u/nruimveld)\
**Post date:** [April 15, 2021, 12:19pm UTC](https://forum.inductiveautomation.com/t/select-ip-address-from-list/45630/1 "2021-04-15T12:19:20Z")

</div>

ip = system.tag.read(’[System]Client/Network/IPAddress’)  
if ip == ‘10.10.1.100’ or ‘10.10.1.101’ or ‘10.10.1.102’:  
‘do something’

I know there’s a way to shorten the if statement to search through a list to see if the ip address matches one in the list. I can’t remember how. Any help would be awesome!

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 15, 2021, 12:26pm UTC](https://forum.inductiveautomation.com/t/select-ip-address-from-list/45630/2 "2021-04-15T12:26:53Z")

</div>

```auto
if ip in ['1.2.3.4', '1.2.3.5', '1.2.3.6']:
    # do something with ip

```

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [April 15, 2021, 12:40pm UTC](https://forum.inductiveautomation.com/t/select-ip-address-from-list/45630/3 "2021-04-15T12:40:03Z")

</div>

In addition to what @Kevin.Herron said, a general programming technique I use for situations like this that might branch off into other functions would be to map the input (in your case the IP) to different functions with a dictionary. So something like

```auto
 ip_function_map = {
    '1.2.3.4': someModule.foo,
    '1.2.3.5': otherModule.bar,
    '1.2.3.6': anotherModule.fooBar
}

ip = system.tag.read('[System]Client/Network/IPAddress')
try:
    ip_function_map[ip]()
except KeyError:
    # Do default case if you can't find the IP address in dictionary

```
