做一个小图书馆程序
图书馆的书放到一个list里面保存
使用add命令加一本书
使用leda命令减去一本存在的书
如果不存在提示一下
getall:可以查询没有借出去的书
输入.退出程序
#encoding=utf-8
prompt="""
add bookname:to add a book to the library
lend:to lend a book from the library
getall:to list all book from the library
.:to exit the program
"""
print(prompt)
library[]
while 1:
command=input("please input your command")
command=command.strip()
if "add" in command:
library.append(command.split("")[1])
elif "lend" in command:
if command.split("")[1] in library:
library.remove(command.split("")[1])
print("lend book complete!" )
else:
print("the book you lend doesn't exist!")
continue
elif "getall" in command:
if len(library)>=1:
for book in library:
print(book)
else:
print("no book in the library!")
elif"."==command:
break