design a program that asks the user to enter a store sales for each day of the week. The amount should be stored in a list. use a loop to calculate the total sales for the week and display the result in python
1
Expert's answer
2014-10-21T12:54:51-0400
#!/usr/bin/env python3 import sys sales = [] for day in range(1, 8): val = input("Day {0}: ".format(day) ) try: sales.append( int(val) ) except: print("Incorrect value") sys.exit() total_amount = 0 for day in sales: total_amount += day print( "Total amount:", total_amount )
Comments
Leave a comment