How to put an input into a url in Python

Question:

I have an input function

id = input("Enter your ID here: ")

and I wish to add this ‘id’ input into the URL address below accordingly. Is there an easy way for me to go about this?

manager_history_url = (
    "https://fantasy.premierleague.com/api/entry/'id'/history/"

I input the above and it returns a JSON decode error.

Asked By: ILE2091

||

Answers:

You could use an f-string:

manager_history_url = f'https://fantasy.premierleague.com/api/entry/{id}/history/'
Answered By: Mureinik
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.