0

I am on day two of starting to learn Python and already got stuck on what will be a really simple problem. I am trying to do an f-string to type out my name but for some reason, it's saying my syntax is invalid. I typed it in exactly how it is in Matthes' book on page 21 and it's still saying my syntax is wrong.

Here is what I have:

first_name = "adrian"
last_name = "lastname"
# having trouble on line 23
full_name = f"{first_name} {last_name}"
print(full_name.title())

Does anyone see something I am not?

Here's a screenshot of the error message:

screenshot showing error message

martineau
  • 119,623
  • 25
  • 170
  • 301
  • 2
    Never post images of code please. – Julien Feb 26 '20 at 01:14
  • Hi! When asking questions here, always try to post some code to help us out (using the code formatter). Additionally, I totally recommend using https://realpython.com to learn some of these basics. Here is a good link to a page about fstrings: https://realpython.com/python-f-strings/ – IanGabes Feb 26 '20 at 01:19
  • f-strings weren't added until Python 3.6, so perhaps you're using an earlier version of the interpreter (I can't tell from the screenshot). – martineau Feb 26 '20 at 01:20
  • @martineau The image (now removed) showed python 3.8 – Pedro Lobito Feb 26 '20 at 01:22
  • How do I make sure I am running 3.8 on my computer. When I go into my command prompt it says something like 2.6 unless I specifically type in python3 then it says 3.8. How would I know my IDE is using 3.8? – adrian91142 Feb 26 '20 at 01:24
  • @PedroLobito: The screenshot says the **framework** is 3.8, not the interpreter that's running. – martineau Feb 26 '20 at 01:25
  • @adrian91142: `print(sys.version_info)` (after `import sys`) to see what's running. – martineau Feb 26 '20 at 01:27
  • sys.version_info(major=2, minor=7, micro=16, releaselevel='final', serial=0) – adrian91142 Feb 26 '20 at 01:29
  • The interpreter is the program that's running your Python code — and you're using version 2.7.16, not 3.6+ – martineau Feb 26 '20 at 01:29
  • { "cmd" : ["python3", "-u", "$file"] } . This is what I have on there – adrian91142 Feb 26 '20 at 01:32
  • Sorry, but that means nothing to me since I don't know what it is nor even what "framework" (or IDE) you're using. Something isn't configured or installed properly. Also when referencing a book, please mention its title (not just its author). – martineau Feb 26 '20 at 01:55

0 Answers0