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 trialJustin Noor
3,692 PointsWhat are the bracket for in self.current_score = [0, 0] ?
I got this to work but never fully understood what the brackets are for in the self.current_score = [0, 0] line.
class Game:
def __init__(self):
self.current_score = [0, 0]
2 Answers
Andrew Smith
10,947 PointsThe brackets create a list. The first item in the list tracks Player 1's score while the second track's Player 2's score. The method you are asked to create takes the argument which tells you which player scored and you increase either the first or second item in the list based on that argument.
Gerald Wells
12,763 PointsThe brackets is a list that hold default values. Each player starts with a score of 0.
Fredrick Rogers
26,349 PointsFredrick Rogers
26,349 PointsIf I'm looking at this right, it looks as thogh self.current_score is an array that contains the scores for both player one and player two. The brackets denote that data stored is an array.