'How to set Microsoft edge as the default browser in Python with webbrowser module

I am trying to make an AI not totally, with if-else statements in python. I want to ask the user which browser he is going to set as the default browser with the webbrowser module.

The two options are Google Chrome and Microsoft edge. I found it for google chrome but none had posted for Microsoft edge.

here is the code:

import webbrowser
edge_path = "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
webbrowser.get(edge_path).open("google.com")

Please tell me the right code which I have to do.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source