5

In Python, I have a dict has pertinent information

arrowCell = {'up': False, 'left': False, 'right': False}

How do I make an array with i rows and j columns of these dicts?

Anand S Kumar
  • 88,551
  • 18
  • 188
  • 176
hkitano
  • 119
  • 1
  • 3
  • 7

2 Answers2

1

How to make a two dimensional i & j is explained really well on the site already at this: How to define two-dimensional array in python link.

Hope this helps, cheers!

Community
  • 1
  • 1
Aven
  • 72
  • 10
0

Although your problem isn't clear but if you want keys and values of dictionary in form of ndarray you can try this:

l = {'up': False, 'left': False, 'right': False}
a = []
for key, value in l.iteritems():
    temp = [key,value]
    a.append(temp)

result of that will be :

>>> a
[['right', False], ['up', False], ['left', False]]

or you can just try l.items(), result of which will be :

>>> l.items()
[('right', False), ('up', False), ('left', False)]

hope that helps and link given above gives you best way to define two dimensional array.

Prashant Shukla
  • 742
  • 2
  • 6
  • 19