Day 3 of 100 - Datetime and Timedelta Day Day 3 of 3

Datetime and Timedelta Day 3 of 3

Day 3 of 100

A shorter day today, much closer to the hour or so that I committed to than yesterday. The goal today was to create something new with the datetime and timedelta methods. Initially, I was going to refactor and improve my code from day two but I decided to write a small new application. I wrote a simple stopwatch application that prompts the user to start and stop the timer. When the user types start and stop, the program saves the current time to a variable and then I do a little time math to figure out how much time has passed between the two and reports it back to the user:

from datetime import datetime

start = input('Input Start to start the timer: ')
while str.lower(start) != 'start':
    start = input('Input Start to start the timer: ')
start = datetime.now()

stop = input('Input Stop to stop the timer: ')
while str.lower(stop) != 'stop':
    stop = input('Input Stop to stop the timer: ')
stop = datetime.now()

print(f'Your time is: {stop - start}')

I have also made my 100 days of python projects a public repo on Github and have been tweeting my progress in hopes that this will help keep me motivated and on track.