Python Python Collections (2016, retired 2019) Dungeon Game Movement

Dungeon Game Type Error

I keep getting the type error, TypeError: can only join an iterable, in my join method in the while loop.

import random
import os

#draw grib
#pick random location for player
#pick random location for exit door
#pick random locaton for monster
#draw player in the grid
#take input for movement
#move the player, unless invalid move (past edges of grid)
#check for win or loss
#clear screen and redraw grid

CELLS = [(0,0),(1,0),(2,0),(3,0),(4,0),

def get_locations():
    return random.sample(CELLS,3)

def move_player(player,move):
    #Get the player's location
    #If move == LEFT, x-1
    #If move == RIGHT, x+1
    #If move == UP, y-1
    #If move == DOWN, y+1
    return player

def get_moves(player):
    moves = ["LEFT","RIGHT","UP","DOWN"]
    if x == 0:
    if x == 4:
    if y == 0:
    if y == 4:

    #If player's y == 0, they can't move up
    #If player's y == 4, they can't move down

def clear_screen():
    os.system('cls' if == 'nt' else 'clear')

moster, door, player = get_locations()

while True:
    valid_moves = get_moves(player)
    print("Welcome to the dungeon")
    print("You're currently in {}".format(player))
    print("You can move {}".format(", ".join(valid_moves)))
    print("Enter QUIT to quit")

    move = input("> ")
    move = move.upper()

    if move == "QUIT":
    #Good move? Change the player postition
    #Bad move. Don't change anything
    #On the door? They win
    #On the monster? They lose
    #Otherwise. Loop over again

1 Answer

53,478 Points

Your get_moves function doesn't have a return statement. It should return moves.