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 trial
How do you know what the player argument will be like?
I don't really get the question again!...
Add a score method to Game that takes a player argument that'll be either 1 or 2. Increase that player's value in self.current_score by 1. You'll need to adjust the index (i.e. player = 1 means self.current_score needs to increase).
... how do I know what the player argument will be like? Is it is tuple- like one value for each player? (which is suggested with the info about needing to adjust the index)
self.current_score = [0, 0]
# do some check on player/ player arg
self.current_score = self.current_score + 1
Dan Johnson40,532 Points
The description states the value for player will be restricted to 1 or 2. The comment about adjusting the index is to show that the players' number is not zero based like their score, e.g. player 1's score is stored at index 0 of
self.current_score, so you'll need to account for that.
Here's one way to select between the players:
def score(self, player):
# This can be reduced to one line
if player == 1:
Hmm... I still don't like the question tbh!
It doesn't really explain what current_score is... if it is a tuple of two players scores or different types of score- I can't see the link with the video beforehand too