0

I have written a Python3.7.1 code, and I need to run it in Python3.5 (because I have to run it from Raspberry), an error shows up:

teams = requests.get(f'http://api.football-data.org/v2/competitions/{league}/standings', headers=headers, timeout = 10).json()
SyntaxError: invalid syntax

The error appears on the first comma (...standings', headers...)

I suppose this is because of python3.5 don't support the same things that 3.7.

I have tried to install Python 3.7 in raspberry but have no good results

teams = requests.get(f'http://api.football-data.org/v2/competitions/{league}/standings', headers=headers, timeout = 10).json()

Thanks for the help

mkrieger1
  • 14,486
  • 4
  • 43
  • 54
pauescofet
  • 68
  • 1
  • 10
  • 1
    Possible duplicate of [Python 3 returns "invalid syntax" when trying to perform string interpolation](https://stackoverflow.com/questions/42126794/python-3-returns-invalid-syntax-when-trying-to-perform-string-interpolation) – mkrieger1 Apr 27 '19 at 17:56

1 Answers1

2

The issue here is that the f string is supported since python 3.6. As you are using python 3.5, you can use an equivalent:

url = 'http://api.football-data.org/v2/competitions/{}/standings'.format(league)

Here you can find some information about string formatting.

nero
  • 453
  • 5
  • 11