You are essentially splitting the list, reversing it, then rotating it.
So this works:
>>> st='the price of food is 12 dollars'
>>> li=st.split()[::-1]
>>> n=3
>>> print ' '.join(l[n:]+l[:n])
food of price the dollars 12 is
Or, more directly:
>>> li='the price of food is 12 dollars'.split()[::-1]
>>> print ' '.join(li[3:]+li[:3])
food of price the dollars 12 is
Or, if you want it in a function:
def chunk(st,n):
li=st.split()[::-1] # split and reverse st
return ' '.join(li[n:]+li[:n])
print chunk('the price of food is 12 dollars',3)
The key is:
st='the price of food is 12 dollars' # the string
li=st.split() # split that
li=li[::-1] # reverse it
li=li[3:]+li[:3] # rotate it
' '.join(li) # produce the string from 'li'