Indexed variables

python-novice at gmx.de python-novice at gmx.de
Thu Sep 22 12:34:05 EDT 2005


Hello,

being an almost complete Python AND programming neophyte I would like to ask
the following - very elementary, as I might suspect - question:

How do I do the following flawed things right:

 
a1=a2=0

def f(x):
    if x == a1:
        a1 = a1 + 1
    elif x == a2:
        a2 = a2 + 1


Now if I call f with f(a2) only a1, of course, is incremented because the
if-clause does only check for the value of the input and the values of a1
and a2 are identical.

So how do I define the function such as to discrimate wheter I call it by 
f(a1) or f(a2) ?

Thank you very much,


Peter

-- 
Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko!
Satte Provisionen für GMX Partner: http://www.gmx.net/de/go/partner



More information about the Python-list mailing list