-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')
1
  • 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. Commented Jun 23, 2020 at 4:49

2 Answers 2

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
Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.