A post that remembers its likes and comments
Write code · Medium · §11.2 Drawing the blueprint
Write a class Post that represents a post. When you create a post with Post(author, text), it stores the values it receives in the attributes author and text, and it starts with likes at 0 and comments as an empty list.
like() adds 1 to the likes, and add_comment(msg) adds the comment msg to the end of comments. Grading creates several posts, calls their methods, and then checks the attributes.
Starter code
class Post:
# Write __init__, like, and add_comment here
pass
p = Post("mina", "Photo of the day")
p.like()
p.add_comment("Cool")
print(p.author, p.likes, p.comments)Solve this problem in your browser
Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.