I've been searching the internet for the answer to my problem, but to no avail. I'm trying to put data into rows and columns, but I have variables and I thought that I had found the answer to my problem, but it wasn't a solution to the variable part of it. Is there a way that I could modify this method a little bit to include variables or is there another way to do this? Found from this answer: https://stackoverflow.com/a/3685943/17289826
#inputs
name = input("Who are you? ")
supermarket = input("Where are you going? ")
date = input("What day is it? ")
item = input("What are you buying? ")
price = float(input("How much is the item you are buying? "))
quantity = float(input("How many are you buying? "))
vehicle = input("How do you plan to get there? ")
commute_cost = float(input("How much does that cost one way? "))
#process
total = price * quantity
total_commute_cost = commute_cost * 2
trip_total = total + total_commute_cost
#data for column
data = '''\
Item Price Quantity Total
item price quantity total'''
#making the table into columns and rows
rows = [ line.strip().split(' ') for line in data.split('\n') ]
cols = zip(*rows)
col_widths = [ max(len(value) for value in col) for col in cols ]
format = ' '.join(['%%%ds' % width for width in col_widths ])
#output
print(" ")
print("Shopper name:", name)
print(" ")
print(supermarket)
print(date)
print(" ")
for row in rows:
print (format % tuple(row))
But it comes out as: Item Price Quantity Total item price quantity total