fuzzywubby
Forum Guru
Gusto ko sanang gawin is maread yung product name and price. Pero yung nagagawa ko palang is iread yung product name lang sa loob ng file, hindi nasasama yung product price. Ano po kaya kulang sa code ko?
CODE:
PRODUCT LIST (products.txt)
OUTPUT (not the required output):
CODE:
Python:
def transact(): # DI BINABASA YUNG PRICE!!!!
print("<Transact Sales>")
temp = open("temp.txt", "x")
inputs = []
if inputs != '':
while True:
inp = input("Product Name (type 'x' to stop the transaction): ")
if inp == 'x':
temp.close()
os.remove("temp.txt")
break
else:
inputs.append("Product Name: " + inp)
with open("products.txt", "r") as prod:
lines = prod.readlines()
with open("temp.txt", "a") as temp:
with open("LOGBOOK.txt", "a") as log:
for line in lines:
if str("Product Name: " + inp) in line:
temp.write(line)
log.write(line)
PRODUCT LIST (products.txt)
OUTPUT (not the required output):
