Python reverse tokens in line

I have the following line:

apple.orange.red.green.yellow 

How can I cancel it to get the following:

 yellow.green.red.orange.apple 
+4
source share
2 answers

I like this (more readable?) One:

 >> s = "yellow.green.red.orange.apple" >> '.'.join(reversed(s.split('.'))) 'apple.orange.red.green.yellow' 
+7
source
 '.'.join(s.split('.')[::-1]) 
+6
source

All Articles