New user practicing lists and loops. My goal is create two list from my own input (range is 2 for quick testing, but want to get to 10). I have hit a wall on two problems:
- I would like my lists to sit side by side ie.
First Name \t\t\t $77
Next Name \t\t\t $16
- I don't know how to change my types so that int or float is not iterable error does not persists. I believe it'll help with my coded out max/min statements
My code:
list1 = []
list2 = []
count = 0
for i in range(2):
customers = input("Customers name? ")
list1.append(customers)
spent = float(input("Amount spent? "))
list2.append(spent)
count += spent
averageSpent = count / 2 # change this when changing range
print("Name\t\t\tAmount")
# won't print side by side. how to use zip()?
print((*list1 + list2), sep = "\n")
print("Total spending:\t\t $", count)
print("Average spending:\t $", averageSpent)
# keep getting 'object is not iterable'
#print("Most money spent:\t $", max(spent))
#print("Least money spent:\t $", min(spent))
My output is currently:
Customers name? work
Amount spent? 45
Customers name? please
Amount spent? 65
Name Amount
work
please
45.0
65.0
Total spending: $ 110.0
Average spending: $ 55.0
Thank you!