Nov-29-2017, 11:03 PM
I am working on my class project and am having some difficulty getting my print statement to format "neatly". Teacher wants it to look like this when it prints-- ex.'TrapperKeeper________$3.99________13' So, 'product', 'price' and 'quantity'
I am also having similar issues formatting the text I am saving in the .txt file at the end (want to have each field separated by a ' : ')
Here is the code for the first issue:
I am also having similar issues formatting the text I am saving in the .txt file at the end (want to have each field separated by a ' : ')
Here is the code for the first issue:
def calculateTotal(products, prices, item_nums, quantity): subtotal = 0 partial_summary = '' order_total = 0 print() print('Items ordered list') print('------------------') width = 6 a = 0 b = 0 t = len(item_list) while b < t: qty = float(quantity_list[b]) a = int(item_list[b]) price = float(prices[a]) subtotal = (qty * price) order_total = order_total + subtotal print(products[b], '\t\t\t', '$', prices[a], '\t\t', quantity) b = b + 1And this is the save to file script, which is ugly, but functional. I just need it to format more neatly as well. I have always had trouble with formatting things to actually look readable and nice, which may be my project over the holidays.
def data_save(): fileWrite = open('OrdersArchive.txt', 'a') fileWrite.write(str(now)) fileWrite.write(str(cust_name)) fileWrite.write(str(street)) fileWrite.write(str(city)) fileWrite.write(str(state)) fileWrite.write(str(zipcode)) fileWrite.write(str(order_summary)) fileWrite.write(str(order_total)) print() return () data_save()