Print book info

Report a typo

Your task is to write a function print_book_info(title, author=None, year=None) that prints information about a book. Arguments author and year are optional, so be ready that they might equal None.

You don't have to read the input. The information about a book will be passed to your function, and it should output it in the right format.

See the samples below to understand the output format.

The knowledge of if-elif-else statements is expected in this task. If it's not the case, please proceed to the next challenge.

Sample Input 1:

title: War and Peace
author: Leo Tolstoy
year: 1869

Sample Output 1:

"War and Peace" was written by Leo Tolstoy in 1869

Sample Input 2:

title: Crime and Punishment
author: None
year: 1866

Sample Output 2:

"Crime and Punishment" was written in 1866

Sample Input 3:

title: The Chronicles of Narnia
author: C. S. Lewis
year: None

Sample Output 3:

"The Chronicles of Narnia" was written by C. S. Lewis

Sample Input 4:

title: Harry Potter
author: None
year: None

Sample Output 4:

"Harry Potter"
Write a program in Python 3
def print_book_info(title, author=None, year=None):
# Write your code here
pass
___

Create a free account to access the full topic