I am attempting to call a value that is defined within a dictionary creation function. The current issue is the calling of i as an input when it is not defined.
Current code:
mass_list=[10.0,15.0,20.0]
def dict_by_masslist(mass_list,input_value):
dict_created=[]
for i in mass_list:
dict_created.append((i,inputvalue))
dict_created=dict(dict_created)
return dict_created
pt_dict_pre_names=dict_by_masslist(mass_list,'pt_'+str(int(i))+'_pre')
Goal output:
pt_dict_pre_names = {10.0: 'pt_10_exp', 15.0: 'pt_15_exp', 20.0: 'pt_20_exp'}
This function will be used to not only name things but generate dictionaries of data. When used outside of the function this scripts works as expected.