On Aug 21, 4:38 am, Ant <[EMAIL PROTECTED]> wrote: > On Aug 20, 11:47 pm, [EMAIL PROTECTED] wrote: > ... > > > Thanks for the help. By the way I am trying to learn the python after > > work and on weekends. If it was a dumb question, to this group, I will > > not bother you all again. > > 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() > > -- > Ant... > > http://antroy.blogspot.com/ I tryed your code and got an error message #I use Wing IDE: Python 2.2.3 (#42, May 30 2003, 18:12:08) [MSC 32 bit (Intel)] Type "help", "copyright", "credits" or "license" for more information. >>> Evaluating lines 1-16 from truckStops.py <string>:7: Warning: 'yield' will become a reserved keyword in the future Could not execute because an error occurred: invalid syntax: <string>, line 7, pos 19: yield stops, wage
-- http://mail.python.org/mailman/listinfo/python-list