-1

The list are below

second_list = ['C']
first_list =  ['A', 'B']
third_list  = ["D"]

Expected out is below

the firstlist is A,B the second_list is C and thirdlist is D

psudo code

print (f'the firstlist is {j for j in first_list } the second_list is {for j for j in second_list} and thirdlist is {for j for j in third_list')
aysh
  • 493
  • 1
  • 11
  • 23
  • aysh, it's not really good form to change your question in such a way that it invalidates all current answers, especially if it's been closed and can collect no *more* answers. Simply ask another question if that's your desire, there's no real limit. Have rolled it back. – paxdiablo Jun 23 '20 at 04:49

2 Answers2

1

Your pseudo-code is very close but you're better off using string.join to create the comma-separated lists (the expressions in f-strings can be arbitrarily complex):

second_list = ['C']
first_list =  ['A', 'B']
third_list  = ["D"]

print (f'the firstlist is {",".join(first_list)} the second_list is {",".join(second_list)} and thirdlist is {",".join(third_list)}')

Output:

the firstlist is A,B the second_list is C and thirdlist is D
paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
1

you can use join

second_list = ['C']
first_list =  ['A', 'B']
third_list  = ["D"]
print (f'the firstlist is {",".join(first_list)} the second_list is {",".join(second_list)} and thirdlist is {",".join(third_list)}')
the firstlist is A,B the second_list is C and thirdlist is D
Kuldeep Singh Sidhu
  • 3,748
  • 2
  • 12
  • 22