0

l = ['a','b']

Output > the elements in list are '%a','%b'

l = ['a','b','c']

Output > the elements in list are '%a','%b','%c'

Like for any number of elements we need to add the elements in the list are and also with express with percentage %

  • Does this answer your question? [Concatenate item in list to strings](https://stackoverflow.com/questions/12453580/concatenate-item-in-list-to-strings) – Gino Mempin May 01 '20 at 00:08

1 Answers1

3

You can use f-strings and join.

sub_str = ", ".join(f"'%{e}'" for e in l)
print(f"the elements in the list are {sub_str}")
modesitt
  • 7,052
  • 2
  • 34
  • 64