Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialjiyoung oh
6,324 Pointsself.monster or self.monsters
In this part..
while self.player.hit_points and ( self.monster or self.monsters):
print(self.player) # call __str__: player info.
self.monster_turn()
self.player_turn()
self.cleanup()
I think
self.player.hit_points and self.monster
is enough cause if self.monster is false then automatically self.monsters also false. and there's no real case of self.monster is false and self.monsters is true. any idea?
1 Answer
Steven Parker
231,271 PointsThese variables represent different things. First, self.monster is a monster that you are fighting right now. But self.monsters (plural) is a list of monsters that you will encounter in the future.
So self.monster will be "false" (empty) and self.monsters will be "true" (not empty) when you are not currently fighting, but you still have more monsters to find.
It's important to check both here because the game is not over if you still have monsters to find.
jiyoung oh
6,324 Pointsjiyoung oh
6,324 PointsThank you for detail answer! I misunderstand the rule of the game .. now understand why need to use both!