I am trying to write a program that will measure a user's typing speed however I cannot get the loop where the user inputs to terminate when the time is up. I want the loop to stop as soon as the time is finished.
from datetime import datetime, timedelta
text = 'Hello My name is matthew'
def some_function(duration):
end_time = datetime.now() + timedelta(seconds=duration)
while datetime.now() < end_time:
answer = input('Type the following: ' + text + '\n\n')
duration = int(input('How long do you want to test yourself: '))
some_function(duration)