I want to be able to increment the contents in the {} by referencing the variable 'count' as I want it to print out a different part from the list 'nodes' each time it iterates through
count = 0
while len(nodes) > count:
print("ltm node {} \n".format(*nodes))
count = count+1
print(" address {} \n".format(*nodes))
count = count+1
I cant for the life in me figure it out of find it documented anywhere
Below is the full code
nodes = []
node_qty = int(input("Number Of Nodes: "))
count = 1
print("Enter the node details ")
while len(nodes) < node_qty*2:
item1 = input("Enter Node %d Name: " % count)
nodes.append(item1)
item2 = input("Enter Node %d IP: " % count)
nodes.append(item2)
count = count+1
count = 0
print("\n"+"List of nodes:")
while len(nodes) > count:
print("ltm node {0} \n".format(*nodes))
count = count+1
print(" address {1} \n".format(*nodes))
count = count+1
Below is a transcript of it in action:
> Number Of Nodes: 2 Enter the node details
>
> Enter Node 1 Name: Server1
>
> Enter Node 1 IP: 192.168.1.1
>
> Enter Node 2 Name: Server2
>
> Enter Node 2 IP: 160.10.10.1
>
> List of nodes:
> ltm node Server1
>
> address 192.168.1.1
>
> ltm node Server1
>
> address 192.168.1.1
At the moment it only shows the details for index 0 and 1 as it is hard coded, but given the 'count' variable increments I would like to use this variable in the curly braces in place of the fixed numbers
(only started learning python yesterday so hopefully the code isn't too sloppy :))