Just use enumerateto help your key generation task and forscroll through each item in the list.
Here you go:
google_dict = dict()
google_price_data = [317.68,396.05,451.48,428.03,516.26,604.83,520.63,573.48,536.51,542.84,533.85,660.87,728.9]
for i, item in enumerate(google_price_data, start=1):
google_dict[i] = item
print google_dict
Output:
{
1: 317.68,
2: 396.05,
3: 451.48,
4: 428.03,
5: 516.26,
6: 604.83,
7: 520.63,
8: 573.48,
9: 536.51,
10: 542.84,
11: 533.85,
12: 660.87,
13: 728.9
}
source
share