-1

I'm trying to write a function to choose a website over several saved URLs. My function looks like this:

website = ''
def choose_website(website_name):
  nfl = 'https://www.nfl.com'
  nba = 'http://www.nba.com'
  fifa = 'http://www.fifa.com'
  If website_name = "nfl":
      website = nfl
  elif website_name = "nba":
      website = nba
  elif website_name = "fifa":
      website = fifa
  else:
      print 'Invalid website, please try again'
choose_website(raw_input("Please insert website(nfl/nba/fifa): ")

In short, I store the websites URLS in their names, and I ask the user to enter the names and this will store the desired website URL in the "website" variable. However when I try to run this, I received a syntax error:

  If website_name = "nfl":
            ^
SyntaxError: invalid syntax

Process finished with exit code 1

I have no idea why it does that, can anyone help me? I'm using Python 3.4

Alon
  • 99
  • 1
  • 9

1 Answers1

0

As people say python is case sensitive. Change If to if and replace = to double == more details in the value-comparisons

  if website_name == "nfl":
  #^^             ^^
      website = nfl
  elif website_name == "nba":
  #                 ^^
      website = nba
  elif website_name == "fifa":
  #                 ^^
      website = fifa

and please read the pep-8

Brown Bear
  • 19,655
  • 10
  • 58
  • 76