Home > other >  On the list element extraction and output
On the list element extraction and output

Time:09-17

If I wrote a list of 1:
 listA=[' test 1 ', '2' test, 'test 3', 4 ' 'test,' test 5] 


Assume that the user wants to add an alias to one of the elements, such as: test 1 (alias)

How should I according to the index of listing 1, record the individual elements of an alias, and output

CodePudding user response:

Don't understand the subject

CodePudding user response:

reference 1st floor chuifengde response:
don't understand the meaning of title

I settled, I'm sorry

CodePudding user response:

Test listA=[' 1 ', '2', 'test 3', 4 ' 'test,' test 5]

ListA=[x + "alias" if x=='2' test else for x x in listA]
Print (listA)
  • Related