Can a Python function remember its previous outputs? [duplicate]
问题 This question already has answers here : What is the Python equivalent of static variables inside a function? (26 answers) Closed last year . Is there a way that a function can remember its previous output and use that value during the next call to the function? For instance, assume there is a function, runningTotal with a single argument x that returns x on the first call to runningTotal but x + prevOutput for every call after that. Is there a way to write such a function in python? I am