This is my first time asking a question here, and I am new to programming so be gentle. I am attempting to create a code in which the user enters sales for each day of the week and the functions display the sales for each day and display the day with the highest sales/average sales/act.
The intended result would be something like:
Mondays sales: $200
Tuesdays sales: $100
Wednesday sales: $50
Thursday sales: $75
Friday sales: $100
Saturday sales: $250
Sunday sales: $75
Highest sales achieved on Saturday with $250
However, now the results are being printed 7 times each and I do not know how to reference the max value with the related day
Here is what I have so far:
days_week=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]
def fillList(salesList):
for index in range(len(days_week)):
user_input=int(input("Enter sales for "+ days_week[index]+": " ))
salesList.append(user_input)
def showSales(salesList):
for sales in salesList:
for index in range(len(days_week)):
print(days_week[index],"sales: $", sales)
def highestSales(salesList):
print("Highest sales of the week was achieved on",max(salesList))
def main():
salesList=[]
fillList(salesList)
showSales(salesList)
highestSales(salesList)
main()
After making the recommended changes, the program now "works," displaying the day's sales as intended.
days_week=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]
def fillList(salesList):
for day in days_week:
user_input=int(input("Enter sales for "+ day+": " ))
salesList.append(user_input)
def showSales(salesList):
for num in range(len(days_week)):
print(days_week[num],"sales: $", salesList[num])
def highestSales(salesList):
print("Highest sales of the week was achieved on",max(salesList))
def main():
salesList=[]
fillList(salesList)
showSales(salesList)
highestSales(salesList)
main()
However, I am trying to display the day in which the most sales occured. Is it possible to append the two lists together? Or is there a simple way of displaying the day with the largest user input?