We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 71f5b39 commit 2a1d2b8Copy full SHA for 2a1d2b8
Week04/fn_w_counter_gamze_kilinc.py
@@ -0,0 +1,17 @@
1
+def fn_w_counter() -> tuple[int, dict[str, int]]:
2
+ """
3
+ Counts function calls with caller information.
4
+
5
+ :return: A tuple containing total call count and a dictionary
6
+ mapping caller names to their call counts.
7
8
+ if not hasattr(fn_w_counter, "_total_calls"):
9
+ fn_w_counter._total_calls = 0
10
+ fn_w_counter._callers = {}
11
12
+ caller = __name__
13
14
+ fn_w_counter._total_calls += 1
15
+ fn_w_counter._callers[caller] = fn_w_counter._callers.get(caller, 0) + 1
16
17
+ return fn_w_counter._total_calls, fn_w_counter._callers
0 commit comments