7

I have a problem here.

I don't know why this code does not work.

newline = '\n'
tasks_choosen = ['markup', 'media', 'python_api', 'script', 'style', 'vue']
print(f'{ newline }### Initializing project with the following tasks: { ' '.join(tasks_choosen) }.{ newline }')

Error:

File "new-gulp-project.py", line 85

print(f'{ newline }### Initializing project with the following tasks: { ' '.join(tasks_choosen) }.{ newline }')

SyntaxError: f-string: expecting '}'

Can anyone help me?

Thanks

RamoFX
  • 510
  • 2
  • 9
  • 17

2 Answers2

17

Because you use single quotes twice you get: print(f'{ newline }### Initializing project with the following tasks: { ' instead of

print(f'{ newline }### Initializing project with the following tasks: { ' '.join(tasks_choosen) }.{ newline }')

Use double quotes inside:

print(f'{ newline }### Initializing project with the following tasks: { " ".join(tasks_choosen) }.{ newline }')

vrnvorona
  • 397
  • 3
  • 8
4

Python is getting confused as you are using ' ' (single-quotes) for the f-string and ' ' (single-quotes) just before the join, so its getting confused as to where your f-string actually ends. Replace the ' ' with " " just before the .join() and it should work :)