2017-04-18 23 views
-3

我一直在做这个游戏一段时间,但我一直有这个重复出现的问题。出于某种原因,第一个支架未标记最后一个支架,使其无法运行。有没有人有解决这个问题?语法错误位于最后一行,为了便于查找,我放了一个星号*来自嵌套字典的定义的SyntaxError

game = {'Room 1': 
      {'occupant': 'Narrator', 
      'option': 
       {'text': 'Do you want to start? (Yes or No)', 
       'Yes': 'Milwaukee', 
       'No': 'Dumpsterr' 
       } 
     }, 
    {'Milwaukee': 
     {'occupant': 'Giannis', 
     'option': 
      {'text': 'Do you want to go hit the weight room?(Yes or No)', 
      'Yes': 'Weight Room', 
      'No': 'Dumpster' 
      }     
     },   
    {'Weight Room': 
     {'occupant': 'Giannis', 
     'option': 
      {'text': 'Lets get started (Yes or No)', 
      'Yes': 'Giannis Thanksgiving party', 
      'No': 'Dumpster' 
      }     
     }, 
     {'John Hammond': 
     {'occupant': 'John Hammond', 
     'option': 
      {'text': 'Hey your taking up my valuabe XBOX time. Intrested in this team yes or no?(Yes or No)', 
      'Yes': 'Draft', 
      'No': 'Undrafted' 
      } 
     }, 
     {'John Hammond house': 
     {'occupant': 'John Hammond wife', 
     'option': 
      {'text': 'Welcome to the Hammond house hold! Hi honey would you like some cookies? - Mrs.Hammond(Yes or No)', 
      'Yes': 'Draft Day', 
      'No': 'How Dare You' 
      } 
     }, 
     {'Draft Day': 
     {'occupant': 'Adam Silver', 
     'option': 
      {'text': 'Welcome to the NBA draft! With the tenth overall pick you have been selected? Do you accept (Yes or No)', 
      'Yes': 'Winner', 
      'No': 'Undrafted' 
      } 
     }, 
     {'Dumpster': 
     {'occupant': 'Dennis Rodman', 
     'option': 
      {'text': 'Welcome to the dumpster! I know im a fool. To get away you have to restart. Would you like to restart?. (Yes or No)', 
      'Yes': 'Room 1', 
      'No': 'Dumpster' 
      } 
     }, 
     {'How dare you': 
     {'occupant': 'John Hammond', 
     'option': 
      {'text': 'How dare you disrespect my wifes cooking you monster! Good luck now getting draft idiot. Would you like to restart? - John Hammond(Yes or No)', 
      'Yes': 'Room 1', 
      'No': 'Room 1' 
      } 
     }, 
     {'Undrafted': 
     {'occupant': 'Nobody', 
     'option': 
      {'text': 'You had your chance... would you like a redo? (Yes or No)', 
      'Yes': 'Room 1', 
      'No': 'Undrafted' 
      } 
    * } 
+1

你有一个尾随逗号。这会导致错误。你应该发布你收到的错误的完整追溯,而不是我们猜测! –

+0

在本代码的最后,有一个悬空的逗号和至少三个未封闭的大括号。我认为你没有粘贴你的所有代码。 – Prune

+0

这照顾了悬崖的逗号,但是你现在在最后一行有一个多余的星号,并且正如我刚刚提到的那样打开了大括号。 – Prune

回答

1

您在每个数据部分都有一个未封闭的大括号。例如:

{'How dare you': 
    {'occupant': 'John Hammond', 
    'option': 
     {'text': 'How dare you disrespect my wifes cooking you monster! Good luck now getting draft idiot. Would you like to restart? - John Hammond(Yes or No)', 
     'Yes': 'Room 1', 
     'No': 'Room 1' 
     } 
    }, 
    {'Undrafted': 
    {'occupant': 'Nobody', 
    'option': 
     {'text': 'You had your chance... would you like a redo? (Yes or No)', 
     'Yes': 'Room 1', 
     'No': 'Undrafted' 
     } 
* } 

您还没有关闭,标题为“你怎么敢”或“落选”的章节。每个有三个左括号,只有两个右括号。它看起来好像每个部分的数据都会遇到这个问题。

顺便说一句,任何合理的智能文本编辑器都会为你配上大括号。即使vim做到了。 :-)

+0

大声笑谢谢你,我是一个新手,所以我非常感谢你的帮助。 – WYXZANDER