Timeline for how to convert an array to a dict in python
Current License: CC BY-SA 3.0
4 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 30, 2014 at 18:04 | vote | accept | city | ||
| Sep 30, 2014 at 5:15 | comment | added | mgilson |
@city -- What version of python are you using? If you're on python2.6, then dict-comprehensions haven't been created yet. You'd need to fall back on the old dict constructor: dict(('item{0}'.format(i), x) for i, x in enumerate(arr))
|
|
| Sep 30, 2014 at 4:57 | comment | added | city | why I got invalid syntax Error when I tested your code? There is an arrow pointing to 'for'. I did not change anything. | |
| Sep 30, 2014 at 4:41 | history | answered | DSM | CC BY-SA 3.0 |