图书馆小程序

做一个小图书馆程序

图书馆的书放到一个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

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,449评论 0 10
  • 物理内存和虚拟内存的关系 进程容器中4GB空间的内容分布 在所谓的4GB空间内,系统内核占据了高2GB的空间,普通...
    Asura_Luo阅读 743评论 0 0
  • 《尘埃落定》,历时12小时44分把这本小说看完,我一路奔走的心也随着二少爷悠悠上升的灵魂而尘埃落定。没有太多悲哀的...
    月华无声阅读 825评论 0 0
  • 晚上做了个梦,以前的同学约着徒手爬了很高的山,还有kyc约第二天又去离他家很近的地方游玩。不知道是什么含义,可能是...
    Kilungly阅读 133评论 0 0