I have the following string:
apple.orange.red.green.yellow
How can i reverse it to get the following:
yellow.green.red.orange.apple
I like this (more readable?) one:
>> s = "yellow.green.red.orange.apple"
>> '.'.join(reversed(s.split('.')))
'apple.orange.red.green.yellow'
'.'.join(s.split('.')[::-1])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With