f-string python invalid sysntax -
i trying learn code in python , have 0 knowledge in programming languages our there , encounter problem in it, in trying use f-string function.
my python version 3.6.2
and here's code trying run
greeting = 'hello' name = 'john' message = f'{greeting} {name}. welcome!' print(message)
and here's error shows me.
file "/users/rq/desktop/intro.py", line 16 message = f'{greeting} {name}. welcome!' ^ syntaxerror: invalid syntax [finished in 0.0s exit code 1]
i using mac 10.12.6 os version
i removed default python 2.7 version in it.
what should fix it?
here answer this
greeting = 'hello' name = 'john' message = '{} {} welcome'.format(greeting,name) print (message)
or
message = greeting + " " + name + " " + "welcome" print (message)
Comments
Post a Comment