Skip to main content

Python example to use zip built-in function

Python code below use zip built-in function to display the list and display the sequence.
The code below just display the list, but using subprocess or fabric module it can be expanded to connect or do remote tasks on the specified servers.

Here's an example code on how to use zip built-in function.

def main_func():

    xservers = ["WebServer", "MailServer", "MonitoringServer", "KibanaServer", "DatabaseServer", "TestServer", "NetboxServer"]
    xips = ["192.168.25.1", "192.168.25.2", "192.168.25.3", "192.168.25.4", "192.168.25.5", "192.168.25.6", "192.168.25.7"]

    for indexx, itemx  in enumerate(zip(xservers, xips), start=1):
        print(indexx, itemx[0], "=", itemx[1], " ==> VM with platform services")


if __name__ == "__main__":
    main_func()
    
itemx[0] ===> refers to xservers
itemx[1] ===> refers to xips

Sample output of the above code:








Don't put off your good work for another day. The time is now, no one knows when you will give a full account to what you have done.
1 Thessalonians 5:2: "for you yourselves know perfectly that the day of the Lord will come like a thief in the night."

Comments