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 trialAndy McDonald
Python Development Techdegree Graduate 13,801 PointsIncreased size of attribute with function and random.choice() began having an error I've never seen before.
In the Final Product lesson https://teamtreehouse.com/library/final-product
I added the following code to create the option to select difficulty:
def select_difficulty(self):
difficulty = input('How good is your memory? Choose one of the following: \n pot smoker\n memory pimp\nEnter memory level: ')
pimp_options = ['Kay', 'Way', 'Ray', 'Hay', 'Bay', 'Way', 'Tay', 'Que']
pimp_columns = ['E', 'F', 'G', 'H']
if difficulty == 'memory pimp':
self.grid = 8
for i in pimp_columns:
self.column_options.append(i)
for i in pimp_options:
self.card_options.append(i)
if difficulty == 'pot smoker':
pass
I got the following error and I dont know what it means:
File "/home/treehouse/workspace/game.py", line 111, in <module>
game.run_game()
File "/home/treehouse/workspace/game.py", line 89, in run_game
self.set_cards()
File "/home/treehouse/workspace/game.py", line 28, in set_cards
random_location = random.choice(list(available_locations))
File "/usr/local/lib/python3.9/random.py", line 346, in choice
return seq[self._randbelow(len(seq))]
IndexError: list index out of range
Any help would be greatly appreciated <3
Megan Amendola
Treehouse TeacherMegan Amendola
Treehouse TeacherHi! Can you share a snapshot of your workspace so we can see all of the code?