Select IP Address from List

ip =’[System]Client/Network/IPAddress’)
if ip == ‘’ or ‘’ or ‘’:
‘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!

if ip in ['', '', '']:
    # do something with ip
1 Like

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

 ip_function_map = {
    '': anotherModule.fooBar

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