There is no version checking for python installing on the Mac and so if python is already installed it tries to install it and brew throws an error asking if want to re-install breaking the script.
TLDR: Check if python is installed before trying to install it with brew