On Aug 20, 11:47 pm, (e-mail address removed) wrote:
...
It's not so much that it was a dumb question, but that it was asked in
a dumb way
You'll get the most help in this group if you can show
some evidence that you've had a go (the size of this thread ironically
trounces that argument of course ;-) .)
It's better to learn if people give you a critique of your own attempt
at the code, rather than looking at other peoples efforts. There's a
guide on how to ask good questions here:
http://www.catb.org/~esr/faqs/smart-questions.html
For what it's worth, here's a gratuitous version using generators, and
one you should come back to once you've mastered the basics of Python:
def counter(std_rate, over_rate, limit):
stops = 0
while True:
stops += 1
wage = stops * std_rate + max(0, stops - limit) * (over_rate -
std_rate)
yield stops, wage
truck = counter(0.4, 1.4, 22)
for i in range(30):
print "Stopped %s times, with accumulated wage of $%s" %
truck.next()