I'm trying to find a way to write a script that accepts input from the user, After which, it will open webpages. The code looks like this so far:
jurisdiction = input("Enter jurisdiction:")
if jurisdiction = 'UK':
import webbrowser
webbrowser.open('https://www.legislation.gov.uk/new')
webbrowser.open('https://eur-lex.europa.eu/oj/direct-access.html')
elif jurisdiction = Australia:
import webbrowswer
webbrowser.open('https://www.legislation.gov.au/WhatsNew')
else:
print("Re-enter jurisdiction")
This leads to a syntax error at line 3:
File "UK.py", line 3
if jurisdiction = UK
^
SyntaxError: invalid syntax**
I would like to know if there is anything in the code that I have missed or should not have had there? Also, is there an alternative way to do what I am trying to achieve here?
I recommend reading up on Python String Comparison. Easy fix, but you would benefit from a basic understanding of how string comparison does and does not work in Python.
Both UK and Australia need to be Strings as well...
And don't import webbroswer package in the body of your code. You only need to do it once.
import webbrowser
jurisdiction = input("Enter jurisdiction:")
if jurisdiction == 'UK':
webbrowser.open('https://www.legislation.gov.uk/new')
webbrowser.open('https://eur-lex.europa.eu/oj/direct-access.html')
elif jurisdiction == 'Australia':
webbrowser.open('https://www.legislation.gov.au/WhatsNew')
else:
print("Re-enter jurisdiction")