Scope question

Subhash Chandra nospam_yschandra at yahoo.com
Thu Mar 11 02:13:00 EST 2004


Hi,

How can I make counter variable in function foo reference to global counter 
variable in the following code. Generally C programmers tend to write code like 
that I am looking for simple way to do it in python.

--- BEGIN ---
counter = 0

def foo():
   if counter < 10:
     print "count = ", counter
     counter += 1

foo()
--- END ---

regards,
Subhash
--
Remove "nospam_" for direct reply



More information about the Python-list mailing list