Advertisement
Guest User

Untitled

a guest
Dec 11th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. with open("books.txt") as b:
  2. books = b.readlines()[7:]
  3.  
  4. books = [x.strip() for x in books]
  5. books = [x.split(",") for x in books]
  6.  
  7.  
  8. def welcome():
  9. print("Welcome to the Bookstore")
  10. global name
  11. name = input("What is your name? ")
  12. print("Our current list of books are: ")
  13. inventory()
  14.  
  15. def choice():
  16. select = input("Which books would you like? (ID):\n")
  17. global chosen
  18. chosen = []
  19. flag = "y"
  20.  
  21. while flag == "y":
  22. chosen.append(select)
  23.  
  24. flag = input("Would you like to add more books to your cart? (y/n): ")
  25. print(chosen)
  26.  
  27. for chosen in books:
  28. books.index(chosen[0])
  29.  
  30.  
  31. def inventory():
  32. length = len(books)
  33. for i in range(length):
  34. print(books[i][0], books[i][1].strip(), ("$" + books[i][2]).replace(" ", ""))
  35. choice()
  36.  
  37. def receipt():
  38. print("Thank you", name)
  39.  
  40.  
  41. welcome()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement