I'm trying to create a class in Python and the pLink function is giving a "not defined" error message when being called.
class Book:
def __init__(bk, name, ISBN, genre, form, rating, author, language, publisher, link):
bk.name = name
bk.ISBN = ISBN
bk.genre = genre
bk.form = form
bk.rating = rating
bk.author = author
bk.language = language
bk.publisher = publisher
bk.link = link
def __repr__(bk):
rep = 'Book: ' + bk.name + "\n" + "ISBN: " + str(bk.ISBN) + "\n" + "Genre: " + bk.genre + "\n" + "Format: " + bk.form + "\n" + "Rating: " + str(bk.rating) + "\n" + "Author: " + bk.author + "\n" + "Language: " + bk.language + "\n" + "Publisher: " + bk.publisher + "\n" ''
return rep
def pLink(bk):
pl = "Here's the link to purchase the book: " + bk.link + ""
return pl
b1 = Book("Where the Red Fern Grows", 9780399551239, "Children's Literature", "Hardcover", 4.1, a1.name, "English", "Doubleday", "https://www.amazon.com/Where-Fern-Grows-Wilson-Rawls/dp/0399551239/ref=sr_1_1?crid=2UQWGKLQ7KB7F&keywords=where+the+red+fern+grows+hardcover&qid=1663797713&sprefix=where+the+red+fern+grows+hardcove%2Caps%2C107&sr=8-1")
Any ideas on what I'm missing here? It works if I don't indent the function.
