-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'
}
* }
你有一个尾随逗号。这会导致错误。你应该发布你收到的错误的完整追溯,而不是我们猜测! –
在本代码的最后,有一个悬空的逗号和至少三个未封闭的大括号。我认为你没有粘贴你的所有代码。 – Prune
这照顾了悬崖的逗号,但是你现在在最后一行有一个多余的星号,并且正如我刚刚提到的那样打开了大括号。 – Prune