Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Hi, New to coding and cant seem to find the solution for this error (Python)

enter image description here

text = ["this","is","text"]
print(f"hello and {text, end=","}")
Input In [58]
    print(f"hello and {text, end=","}")
                                  ^
SyntaxError: f-string: expecting '}'

I am trying to remove brackets and commas while using an f string

……………………

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It appears you are trying to print the contents of the list after the hardcoded string. So your code is first printing "hello and" and then the string representation of the list ‘text’. In order to print the elements of the list using an f string you can do:

text = ['this','is','text']
print(f"hello and {' '.join(text)}")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading