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 trialLadonna Hill
1,576 PointsBummer! Did you create the `score` method?
What am I missing? I don't understand why I am getting this error message. It looks to me like I have created the 'score' method. Am I way off base or what? Can someone please help?
class Game:
def score(self, player):
player = input("Input 1 or 2: ")
return player
def __init__(self):
self.current_score[player - 1] += 1
2 Answers
Daniel Santos
34,969 PointsHey Ladonna,
You are doing great! You are just dealing with something confusing.
You are suppose to create your method after the constructor method. Also you need to make decisions, so I used the if statement. So if player is 1, I am increasing index [0], if it is player 2 I am increasing index [1]. Here is an example.
class Game:
def __init__(self):
self.current_score = [0, 0]
def score(self, player):
if player == 1:
self.current_score[0] += 1
elif player == 2:
self.current_score[1] += 1
Keep in mind that we are representing/storing the current score of player 1 as index [0] and player 2 as index [1]. This worked for me :)
-Dan
Denny Ho
4,472 Pointsa capital 'S" in current_score in my elif statement. my eye caught it right when i posted it. sorry. thanks
Ladonna Hill
1,576 PointsLadonna Hill
1,576 PointsThanks Dan :)
I will give that a try.
Ladonna
Ladonna Hill
1,576 PointsLadonna Hill
1,576 PointsHey Dan,
I tried it and it worked! Thanks so much :)
Ladonna
Daniel Santos
34,969 PointsDaniel Santos
34,969 PointsYou are always welcome!
Denny Ho
4,472 PointsDenny Ho
4,472 PointsHi Dan, I was working on this problem and got the same code you did independently. However, my code does not work. It actually gives the same error message of Bummer! did you create the score method?
any ideas? sorry to sorta hijack the thread.