Question: This is Python coding BTW. I am trying to code a book loaning program, but I am new so I need help. I would like

This is Python coding BTW.

I am trying to code a book loaning program, but I am new so I need help. I would like for them to type in a code for the book that they want (I have the codes stored in a file), the code will then load the cost etc of the book. The user must then input how many copies they would like, and the program will calculate the total price. I would then like for the program to ask them if they want to purchase any more books, and if they do, loop them back to the beginning so that they can order more books. Once they repeat this however many times, I would like the name, quantity and price for every single book they ordered to come up and then print out the total price of everything all together. pls help!

task=input("Enter 'b' to borrow a book, press 'x' to exit. ")

if task.lower()== "b": myfile=open("books.txt", "r+") details=myfile.readlines() while True: book=input("Enter the 8 digit book code. ") if len(book) !=8 print("Your code is not 8 digits long, please try again. ") else: break f = open("books.txt", "r+") #I have a file with all the books, their codes and prices for line in f.readlines(): quantity=input("How many copies of the book do you wish to purchase? ") t = line.split(" ") price = float(t[3]) code = t[1] NameOfBook = t[2] total=(price)* int(quantity) # Ask them if they'd like to purchase more books, if so I would like to then direct them back to "toy=input("Enter the 8 digit book code. ")" print ("Your receipt is:",digits,"," ,name, name2) #I want to repeat this for however many books they'd like to purchase  print ("Your total is ",total) #Then add the total cost of everything together and print it 

After #s are the help that I need, I would like help with making the user able to enter more than 1 book code and a certain quanitity, then print off a receipt and total price

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!