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

Logging: wrong WARNING logged

I am wondering why my code isn't working, how to do I pass this challenge?

starter.py
import logging

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

# Write your code below here
logging.debug(print("hi"))
logging.warning(print("The French have the Grail"))

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Riley Ittidecharchoti! You're really close, but you need to remove the print() parts. The print() function simply prints something, but it has no return value, so it returns None which will then be cast to a string and recorded in the log file as "None", which isn't what you're wanting.

It would be similar to doing the following:

print(print("Hi"))

If you were to run that code, it would first print the word "Hi" to the console, then on a new line it would print the word "None" because you're telling it to print what was returned by the print("Hi") portion.

So instead of:

logging.warning(print("The French have the Grail"))

You just need:

logging.warning("The French have the Grail")

Hope this helps! :sparkles:

thank you so much!!