-1

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

........................

Passiv AHS
  • 13
  • 1
  • It stopped giving me an error message, however the issue of the commas and brackets remain. – Passiv AHS Oct 30 '22 at 17:29
  • 1
    https://stackoverflow.com/questions/12453580/how-to-concatenate-join-items-in-a-list-to-a-single-string – Thierry Lathuille Oct 30 '22 at 17:32
  • Does this answer your question? [How to concatenate (join) items in a list to a single string](https://stackoverflow.com/questions/12453580/how-to-concatenate-join-items-in-a-list-to-a-single-string) – Rabinzel Oct 30 '22 at 17:34

1 Answers1

0

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)}")
E Joseph
  • 316
  • 2
  • 8