In Python these kind of things are a lot easier than in C#. Here is a typical example ...
sentence = 'the dog barks'
# create a list of words (default=whitespaces)
words = sentence.split()
# take a look
print words # ['the', 'dog', 'barks']
# now reverse the list of words
rev_words = reversed(words)
# join the reversed list to a sentence again (' '=space)
rev_sentence = ' '.join(rev_words)
# look at rev_sentence
print rev_sentence # barks dog the
# you can do that all on one line
print ' '.join(reversed(sentence.split()))
Those >>> and ... int the code confuse me, so I rewrote it to regular code:
sentence = "a doctor kills your ills with pills and you with bills"
rev_sentence = ""
for i in range(len(sentence.split()),0,-1):
rev_sentence += sentence.split()[i-1] + " "
bills with you and pills with ills your kills doctor a
You might find yourself liking Python as much as you do C#. Just want to point out that there is also a language called "Boo" with a Python syntax that feeds right into C#, using the same compiler and the .NET or Mono environment. This way you can produce rather tight executable (.exe) files. Check out "A Taste of Boo" at: http://www.daniweb.com/code/snippet429.html