Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Python
  3. Question
Python

What is the Python equivalent of static variables inside a function?

Asked by Manish Jhadav Apr 5, 2021 1.7K views 1 answer
Share

About this question

 I have this example in C/C++ and I want the same code for Python

void numbers()
{
    static int count = 0;
    count++;
    printf("count is %dn", count);
}

How to implement static member at a function level as opposed to the class level?If I place a function into a class will it change anything?

Your answer

1 Answer

More Python discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Python Blogs

Guides, tips and career advice on Python from JanBask experts.