RANDALL HOWELL wrote: > I am trying to figure out how to code my stop pay. I > get paid 40 cents a stop for the first 22 stops, and > $1.40 for stops after that. > stops = 24 > if stops < 22: > stopPay = stops * .4 > else: > stopPay = stops * 1.4 > print stopPay > >>>> 33.6 >>>> > well thats not how I get paid, I get paid $8.80 for > the first 22 stops + $2.80 for the last 2 stops. I > know this is a elementary question, but it has got me > stuck.
Just write the code like you wrote your explanation. I only had to change one line: stops = 24 if stops < 22: # First 22 stops are worth 40c each. stopPay = stops * 0.40 else: # For more than 22, we get 8.80 plus 1.40 for each stop over 22. stopPay = 8.80 + (stops-22) * 1.40 Another way to write it is to think about the stops beyond 22 as getting a 1.00 bonus: stopPay = stops * 0.40 if stops > 22: stopPay += (stops-22) * 1.00 but I don't really think that's clearer. -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32