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 trialKris Reid
17,133 PointsHave checked this code in another environment and it works as it should but Workspaces says it's wrong?
Any ideas? My code provides the correct response to the question when used in another python environment!
class Book:
def __init__(self, author, title):
self.author = author
self.title = title
def __str__ (self):
return f'{self.author} {self.title}'
book_one = Book ("John Green", "Paper Towns")
print(book_one)
from book import Book
class BookCase:
def __init__(self):
self.books = []
def add_books(self, book):
self.books.append(book)
1 Answer
Steven Parker
231,269 PointsRemember that the challenge isn't just about creating code that runs. It must also serve a specific purpose. In this case, the example shows that the response is expected to contain the author and title separated by a comma and a space.
Also, an external REPL won't tell you if you're using the formatting taught in the classes. While it's functionally allowed, a space between the function name and the open parenthesis doesn't conform to the PEP8 standard that the challenge is expecting.
Kris Reid
17,133 PointsKris Reid
17,133 PointsThanks for your reply! I did fix it actually - they didn't want it printed out so just removed that part and worked once I sorted the comma too.