Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python- reverse 2 strings in 1 list separately?

Tags:

python

In python, I have this list containing

['HELLO', 'WORLD']

how do I turn that list into

['OLLEH', 'DLROW'] 
like image 957
user2278906 Avatar asked Nov 20 '25 17:11

user2278906


1 Answers

>>> words = ['HELLO', 'WORLD']
>>> [word[::-1] for word in words]
['OLLEH', 'DLROW']
like image 139
jamylak Avatar answered Nov 23 '25 06:11

jamylak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!