خرید بک لینک

Vote count: 0

I have a list of rows...

rows = [2, 21]

And a dictionary of data...

data = {'x': [46, 35], 'y': [20, 30]}

I'd like to construct a second dictionary, dataRows, keyed by the row that looks like this...

dataRows = {2: {'x': 46, 'y': 20}, 21: {'x': 35, 'y': 30}}

I tried the following code, but the values of dataRows are always the same (last value in loop):

for i, row in enumerate(rows):
    for key, value in data.items():
        dataRows[row] = value[i]

Any assistance would be greatly appreciated.

asked 24 secs ago

برچسب: python mapping list,python mapping list dictionary,python mapping list example, نویسنده: استخدام کار تاريخ: دوشنبه 19 مهر 1395 ساعت: 5:14

صفحه بندی