return ' '.join(w[len(w)::-1] for w in s.split()) code example
Example: split and join in python
>>> a = "this is a string"
>>> a = a.split(" ") # a is converted to a list of strings.
>>> print a
['this', 'is', 'a', 'string']
>>> a = "-".join(a)
>>> print a
this-is-a-string