Indexed variables


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:


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,


Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko!
Satte Provisionen für GMX Partner:

Relevant Pages

  • re: variable declaration
    ... a Python programmer. ... cannot tell you whether decorators are or are not declarative. ... ambiguities in these kinds of words. ... I suspect there is a lot of semantics to be played ...
  • Re: Dependencies
    ... I suspect that you're seeing cascading ... >> dependencies (port A depends on port B which depends on Python), ... it's like saying xterm requires python because it ...
  • Re: pythonOCC examples doesnt work?
    ... "I suspect you have the same problem I've run into. ... OpenCV Wiki, but it's not for the faint of heart. ... Uninstall 64-bit Python ... The PythonXY distribution includes pyopencv -- a good set of OpenCV hooks. ...
  • Contacts/Addressbook application - any good Python ones out there?
    ... I'm after an application for managing Contacts ... and as I suspect I will want to 'tune' it a bit Python would be my ...