← Back to challenges

Global Variable

PythonHardlanguage_fundamentals

Instructions

Create a function that returns how often it has been called previously (i.e. return the count value pre-increment).

Examples

counter() ➞ 0

counter() ➞ 1

counter() ➞ 2

counter() ➞ 3

Notes

A global variable is needed for this task.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Little Big Sequence