1

I used the answer here: syntax for creating a dictionary into another dictionary in python as a base to what I used.

I, however, get a syntax error and can't see why.

player.image_dict = {( 0,2,0,0,0,0):  {'idle' : itertools.cycle
                                                       [(pygame.image.load("images/egg_1.png"),
                                                       pygame.image.load("images/egg_2.png"), 
                                                       pygame.image.load("images/egg_3.png")] },               


                     ( 2,4,0,0,2,5):  {'idle' : itertools.cycle
                                                        ([pygame.image.load("images/leaf_1.png"), 
                                                        pygame.image.load("images/leaf_2.png"), 
                                                        pygame.image.load("images/leaf_3.png"),
                                                        pygame.image.load("images/leaf_4.png")])}}

The syntax error refers to the line:

pygame.image.load("images/egg_3.png")] },
Community
  • 1
  • 1
user3384265
  • 173
  • 11
  • 2
    `itertools.cycle[...]` should be `itertools.cycle([...])`. – user4815162342 Mar 23 '14 at 11:55
  • Just an FYI - this is a very poor data structure. If you find yourself embedding too many lists/dicts inside each other - you probably need custom classes, a better way to organize your data, or to rethink your approach. Especially considering those dictionary keys look horrible. – Inbar Rose Mar 23 '14 at 11:58
  • There will be 6 main keys, with 5 of them having 3 inner keys. The only problem I see with making custom classes is that when I loop the game, I'll have to, as far as my knowledge, have checks to see what the stats are (this is what the 0,2,0,0,0 refers). – user3384265 Mar 23 '14 at 12:02

1 Answers1

3

You have the opening brackets the wrong way round:

itertools.cycle([pygame.image.load("images/egg_1.png"),
                 ...

and at the end:

...egg_3.png"] ) },
Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
  • Thanks. Such a silly mistake. This, however, leads to another syntax error: http://pastebin.com/Hc24sM65 Specific line: ( 2,4,0,0,2,5): {'idle' : itertools.cycle – user3384265 Mar 23 '14 at 12:13