Value Of A Key In A Python Dictinary Is Not Updating
I have a weird problem, as I am trying to generate a list of dictionaries to pass them as a parameter to a function. Designing the input 'by hand' looks like this: params = [ #
Solution 1:
params = []
withopen('Test_Tickers.txt') as f:
for line in f:
info = {}
info['q'] = line.rstrip()
info['x'] = "NYSE"params.append(info)
print(info)
I will work
you were updating only one dict object in list ,
to make multiple object you have to define info = {}
inside the loop
Post a Comment for "Value Of A Key In A Python Dictinary Is Not Updating"