Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SyntaxError: f-string: expecting '}'

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

like image 617
RamoFX Avatar asked Dec 11 '22 00:12

RamoFX


1 Answers

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 }')

like image 133
vrnvorona Avatar answered Dec 27 '22 22:12

vrnvorona