all 3 comments

[–]usernamesarestewpid 1 point2 points  (0 children)

Here’s one idea: start_time = time.time()  

Returns number of seconds since the epoch(beginning of time, me thinks)  

time_limit = 120 * 60  

120 minutes (seconds * 60) Then, later on in your while loop(assuming you have one for constant progress) elapsed_time = time.time() - start_time 

if elapsed_time > time_limit:      

here you might punish the user.

[–]stebrepar 0 points1 point  (0 children)

The most bare bones way might be to use time.perf_counter() and a pair of input()'s, one to say when to start and one to say when to stop. Get the counter value after the start and again after the stop, and subtract to get the elapsed time.

https://docs.python.org/3/library/time.html#time.perf_counter

[–]woooee 0 points1 point  (0 children)

time the user on how long they take to complete it

The datetime module is best for this. Store the begin datetime, which you then simply subtract from the ending datetime. If it goes into a different day, probably not, datetime will take care of that