I m getting a error name ch is not defined

0 votes
class Library:
    def __init__(self):
        self.bookname=""
        self.author=""
    def getdata(self):
        self.bookname = input("Enter Name of the Book: ")
        self.author = input("Enter Author of the Book: ")
    def display(self):
        print("Name of the Book: ",self.bookname)
        print("Author of the Book: ",self.author)
        print("\n")
        book=[] #empty list
        ch = 'y'
while (ch=='y'):
    print("1. Add New Book \n 2.Display Books")
    resp = int(input("Enter your choice : "))
if(resp==1):
    L=Library()
    L.getdata()
    book.append(L)
elif(resp==2):
    for x in book:
        x.display()
else:
    print("Invalid input....")
    ch = input("Do you want continue....")
Mar 8, 2021 in Python by CYBER

edited Mar 4, 2025 358 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP