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

Python

Olga Pavlova
Olga Pavlova
2,632 Points

DeprecationWarning

import logging
import random

logging.info("You won't see this")
logging.warn("OH NO")

player = {'location': None, 'path': []}
cells = [(0, 0), (0, 1), (0, 2),
         (1, 0), (1, 1), (1, 2),
         (2, 0), (2, 1), (2, 2)]

def get_locations():
    monster = random.choice(cells)
    door = random.choice(cells)
    start = random.choice(cells)

    if monster == door or monster == start or door == start:
        monster, door, start = get_locations()

    return monster, door, start

Error I get:

treehouse:~/workspace$ python dd_game.py
/home/treehouse/workspace/dd_game.py:5: DeprecationWarning: The 'warn' function is deprecated, us e 'warning' instead
logging.warn("OH NO")
WARNING:root:OH NO
Welcome to the dungeon!

2 Answers

Steven Parker
Steven Parker
230,038 Points

Have you tried replacing "logging.warn" with "logging.warning"? That's what the error seems to be suggesting.

I tried it myself and sure enough, that fixes the issue!

You forgot to link to or mention the course you are doing, but if this is something you did by following along with a video, you might want to report it to the Support folks. They may want to add something to the Teacher's Notes and you could get the "special Exterminator badge". :beetle:

Olga Pavlova
Olga Pavlova
2,632 Points

Thank you Steven! That has worked!