I have created several variables with different values. Then I have created a while to access them one at a time. I would like to know how to access the value of a variable created using a composition of the variable ([base_name] + count)?
For example:
instanceNumber=3
instance1="server1"
instance2="server2"
instance3="server3"
print instance1 --> This prints server1
count = 1
while count >= instanceNumber:
instanceServer = 'instance' + str(count)
print "%s" % instanceServer --> This prints only instance1
# Execute some action on the server
count += 1
I need to get server1, server2, server3 one after the other. I need to do this without using a list or a dictionary.
Thanks