On Fri, 24 Jun 2005 21:53:03 -0700, [EMAIL PROTECTED] wrote: > Apologies if this question seems stupid: How does one write a > function that increments a value in Python? When I tried, the variable > never changed. > The session went like this: >>>> def incr(counter): > counter = int(counter) > counter += 1 > >>>> counter = 1 >>>> incr(counter) >>>> print counter > 1
Why does it need to be a function? Why complicate matters? Isn't it simpler to just do this: counter = 1 counter += 1 print counter -- Steven -- http://mail.python.org/mailman/listinfo/python-list