How to append suffix to strings in a list with Python

1 Answer

0 votes
lst = ['python', 'php', 'java', 'c++', 'c']
 
suffix = '_Y'

lst = [s + suffix for s in lst]

print(lst)
    
    
    
'''
run:
     
['python_Y', 'php_Y', 'java_Y', 'c++_Y', 'c_Y']

'''

 



answered Feb 18, 2023 by avibootz
...