how to maker loops coun t in second in pytho

import time #import the necessary library

sec = 0 #define the varieble that will store the amount of seconds

while True:
    print(sec) #prints the seconds
    time.sleep(1) #time.sleep(amount of seconds) the delay
    sec = sec + 1 # adds the time passed to the counter

Here is what the above code is Doing:
1. It defines a variable called sec that stores the amount of seconds.
2. It has a while loop that runs forever.
3. It prints the value of sec.
4. It waits for 1 second.
5. It adds 1 to sec.
6. It goes back to step 3.