Local vs Global

Lab Python Intermediate 20 points

A global counter = 0 exists. Write increment() that adds 1 to the global counter. Read n, call it n times, and print the counter.

Input

One integer.

Output

The counter.

Example

Input

5

Output

5
Sample input available Sample output available
Editor
Python

Hints

Assigning to a name inside a function makes it local unless you declare it global.

Solution explanation

global lets a function rebind a module-level name. Prefer returning values over changing globals in real programs.

Show solution
counter = 0


def increment():
    global counter
    counter += 1


for _ in range(int(input())):
    increment()
print(counter)
Output
Answer
HOME LEARN COMMUNITY DASHBOARD