I am wanting to automate some data entry for a dictionary that includes several sub-dictionaries. For example: I want to accomplish something like this generalized case:
{C1:{inlet:J1}, C2:{inlet:J2}, C3:{inlet:J3}}
Essentially, I want to be able to populate a dictionary like the above where I can define the range of C1 and J1 easily and then the code automatically populates the dictionary. Basically I want to automate the entry of C1, J1, C2, J2, C3, J3, ........ for the dictionary by identifying a range and then appending the C and J to that number. Or however is easiest to accomplish that, I'm open to any approach that accomplishes this.
Here is my attempt at doing this. I have gotten the C1, C2, C3,... portion to populate but am struggling on how to get the J1, J2, J3, .... portion to work too. Thanks for any help or direction on getting this all set up!
#Define list of C1, C2, C3, ....... where it creates values up to a value defined by a range
def c_values(list1, str1):
str1 += '{0}'
list1 = [str1.format(i) for i in list1]
return(list1)
str1 = 'C'
list1 = range(1,4,1)
result1 = c_values(list1,str1)
print(result1)
#Define list of J1, J2, J3, ....... where it creates values up to a value defined by a range
def j_values(list2, str2):
str2 += '{0}'
list2 = [str2.format(i) for i in list2]
return(list2)
str2 = 'J'
list2 = range(1,4,1)
result2 = j_values(list2,str2)
print(result2)
#Combine result1 and result2 into a dictionary
result3 = dict(zip(result1,result2))
print(result3)
#Build final dictionary
output = {}
inputdata = 'J'
for key,value in result3.items():
for i in result3:
output[i] = {'inlet':inputdata}
print(output)
The output is close to right, but I can't get the J1, J2, J3, etc to populate.