You can use the with statement to interacte with both alerts and prompts too.

withbrowser.get_alert()asalert:alert.do_stuff()

If there’s not any prompt or alert, get_alert will return None.
Remember to always use at least one of the alert/prompt ending methods (accept and dismiss).
Otherwise your browser instance will be frozen until you accept or dismiss the alert/prompt correctly.