Categories
Python Answers

How to append the same string to a list of strings in Python?

Spread the love

Sometimes, we want to append the same string to a list of strings in Python.

In this article, we’ll look at how to append the same string to a list of strings in Python.

How to append the same string to a list of strings in Python?

To append the same string to a list of strings in Python, we can use list comprehension.

For instance, we write

l = [s + my_string for s in my_list]

to append my_string to the end of each string s in the my_list list.

And then we return the values in a new list.

Conclusion

To append the same string to a list of strings in Python, we can use list comprehension.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *