-4

This is my code for print: "url = ("https://etherscan.io/address/%s"address)" and i got SyntaxError: invalid syntax

My Python version is 3.7 and i'm new to python I think %s is the problem, i'm not what replacement of that in Python 3.7

1
  • url = "https://etherscan.io/address/%s" % address this is the way to do python string format. Commented Apr 16, 2019 at 7:42

1 Answer 1

1
url = ("https://etherscan.io/address/%s" % address)
                                         ^

You're missing the % to assign the variable. Alternatively you can use other forms of string formatting:

Using .format()

url = "https://etherscan.io/address/{}".format(address)

Using f strings:

url = f"https://etherscan.io/address/{address}"

Sign up to request clarification or add additional context in comments.

12 Comments

Why do you answer these kind of questions?
To help? It might seem trivial to experienced users..
oh it works! Thanks, coding in python is exciting.
You're welcome, and yes it is! :)
@MattB. Might I also suggest: url = "https://etherscan.io/address/{}".format(address)? ;-)
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.