I am creating a simple basic code as I am gonna use it for learning GUI. So i thought of creating a library sort of code. Its incomplete as this is a main error. Here is the code for it:
total_books = open('Total_books.txt', 'a+')
def lend(numeber_of_books, num_days, code_of_book):
price_per_book = 1
price_per_day = 2
total_price = 0
total_price = price_per_book * numeber_of_books
total_price += numeber_of_books * (price_per_day * num_days)
print(total_price, "is the cost.")
y = code_of_book + "\n"
lend_books.write(y)
total_books.seek(0)
lend_books.seek(0)
lines = total_books.readlines()
print(total_books.readlines())
temp = open('total_books.txt', 'w+')
for x in lines:
if x == code_of_book + "\n":
pass
else:
x.append(temp)
temp.close()
lend(1, 3, "ASFD")
lend_books.close()
total_books.close()
Well, in the start of the file there are two files. You can put anything in them for now. As whatsoever the total_books.readlines()
returns []
. As you can see I tried various stuff.