Ok, so my program's input is the number of days someone worked. They earn .02 a day. Each day they work after the first, their pay doubles...(.04, .08, .16....) my code below displays the days worked and the money earned each day. I think i did it the hard way (not sure what the easy way is) and since i have reassigned dollars, I don't think the counter is working porperly. Can somone point out my error(s) in my code?

def main():
    #get the ending limit
    days = int(input('How manys days were worked?'))
    end = days + 1
    total = 0
    MAX = end
    dollars = 2
    #print table headings
    print()
    print('Days\tDollars')
    print('------------------------------')

    #print the days and the amount of money that was earned that day
    for days in range(2):
        dollars = days * 2
        print(days, '\t', '$',format(dollars / 100,',.2f'))
    for days in range(2, end):
        dollars = dollars * 2
        print(days, '\t', '$',format(dollars / 100,',.2f'))

    #count the days and add the values until the loop stops at the MAX
    for counter in range(MAX):
        total = dollars + total
    print('the amount of money you earned is: $',format(total / 100,',.2f'))
main()

I agree that you are doing it the hard way. Note that dollars is multiplied by two after the print and the addition to total

#get the ending limit
days = int(raw_input('How manys days were worked? '))
total = 0
dollars = 0.02
#print table headings
print('\nDays\tDollars')
print('------------------------------')


#print the days and the amount of money that was earned that day
for today in range(days):
    total += dollars  ## 0.02 on first pass
    print(today+1, '\t', '$',format(dollars,',.2f'))
    dollars *=  2  ## set for next pass
print('the total amount of money you earned is: $',format(total,',.2f'))
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.