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
Ricardo Lousada
7,487 PointsHelp on calling monster,door,player = get_location
Hi,
When calling the function get_location() like this:
monster,door,player = get_location()
i get the following compiling error:
File "/Users/rlousada/Documents/Developer/Python/Varios/dungeon_game.py", line 39, in <module> monster,door,player = get_location()
TypeError: 'function' object is not utterable
Can anyone help?
Thanks.
Ricardo Lousada
7,487 PointsThank you Alexander :) Any way i just discovered the "bug", missing () when returning get_location...
The code is...
CELLS = [(0,0),(0,1),(0,2),
(1,0),(1,1),(1,2),
(2,0),(2,1),(2,2)]
def get_location():
monster=random.choice(CELLS)
door=random.choice(CELLS)
player=random.choice(CELLS)
if monster == door or monster == player or player == door:
return get_location
return monster,door,player
Alexander Davison
65,469 Points Great work! :)
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsCan you show me the get_location() function?
By the Way, you can style code like this:
```python
print("Just some code")
```
will turn into:
print("Just some code")