# 8 strings: `Hello String 0, .. ,Hello String 8`
strings = ["Hello String %d" % x for x in range(9)]
for string in strings: # you can loop over them
print string
print string[6] # or pick any of them
import sys
this = sys.modules[__name__] # this is now your current namespace
for x in range(0,9):
setattr(this, 'string%s' % x, 'Hello')
print string0
print string1
print string2
print string3
print string4
print string5
print string6
print string7
print string8
import requests
import sys
def switch_name(branchNum):
# s is an empty list to start with
s = []
#this FOR loop is purely for creating and storing the dynamic variable names in s
for x in range(1,8,+1):
s.append("BR" + str(branchNum) + "SW0" + str(x))
#this FOR loop is used to read each of the switch in list s and perform operations on
for i in s:
print(i,"\n")
# other operations can be executed here too for each switch (i) - like SSH in using paramiko and changing switch interface VLAN etc.
def main():
# for example's sake - hard coding the site code
branchNum= "123"
switch_name(branchNum)
if __name__ == '__main__':
main()
variables = {}
break_condition= True # Dont forget to add break condition to while loop if you dont want your system to go crazy.
name = “variable”
i = 0
name = name + str(i) #this will be your variable name.
while True:
value = 10 #value to assign
variables.update(
{name:value})
if break_condition == True:
break