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 Write Better Python Buggy Logs Log Messages

Fredric von Stange
Fredric von Stange
3,867 Points

How to solve

I don't understand how to do this and can't find anything in the community posts. Can anyone point me in the right direction?

starter.py
import logging

logging.basicConfig(filename='cc.log', level=logging.DEBUG)

try:
    [1, 2, 3].remove(4)
except ValueError:
    logging.error("tried to remove invalid value")

1 Answer

Ryan S
Ryan S
27,276 Points

Hi Fredric,

I think you may be over-thinking the challenge. You don't need the try and except blocks. In fact all you need is one line (similar to your last line but with a slight modification). The challenge asks for a logging level of "debug".

Remember how to log different levels:

logging.error()
logging.warning()
logging.info()
# ...etc.

Good luck.