book1 = {"Name":"Biology","id":"001","Author":['Alice', 'Bob'],"Copies":5,"Owners":2}
book2 = {"Name":"Chemistry","id":"002","Author":['Alice'],"Copies":3,"Owners":1}
books = [book1,book2]
def adminMenu():
print("Welcome Admin! What do you want to do?")
print("1-List Books")
print("2-Create a book")
print("3-Clean a book")
print("4-Search for a book")
print("5-Change number of copies of book by id")
print("6-Show students borrowed a book by id")
print("7-List Users by id")
print("8-Create User")
print("9-Delete User")
print("10-Exit")
yourChoice = int(input("Your choice: "))
if yourChoice == 2:
while True:
id = input("What is the id you want to give for the book?: ")
for book in books:
if id == book["id"]:
print("This id is already in use!")
else:
break
Hello I'm trying to create a simple library management system using python 3.8.3. I try to code the create a book section and if the book id already exist, the program should ask for the id again but it doesn't seems to work. What's the mistake that I do here?
while True:
id = input("What is the id you want to give for the book?: ")
for book in books:
if id == book["id"]:
print("This id is already in use!")
else:
break